Browse Source

Use Pressbooks coding standards (#131)

pull/132/head
Ned Zimmerman 6 years ago committed by GitHub
parent
commit
743e20f35e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      archive.php
  2. 15
      comments.php
  3. 8
      composer.json
  4. 179
      composer.lock
  5. 12
      footer.php
  6. 6
      functions.php
  7. 22
      header.php
  8. 52
      inc/actions/namespace.php
  9. 11
      inc/activation/namespace.php
  10. 8
      inc/admin/namespace.php
  11. 138
      inc/customizer/namespace.php
  12. 8
      inc/filters/namespace.php
  13. 19
      inc/helpers/namespace.php
  14. 12
      inc/intervention.php
  15. 9
      index.php
  16. 10
      page-catalog.php
  17. 9
      page.php
  18. 19
      partials/book.php
  19. 48
      partials/contact-form.php
  20. 17
      partials/content-front-page.php
  21. 15
      partials/content-none.php
  22. 49
      partials/content-page-catalog.php
  23. 6
      partials/content-page.php
  24. 18
      partials/content.php
  25. 40
      phpcs.ruleset.xml
  26. 15
      search.php
  27. 3
      single.php

9
archive.php

@ -13,7 +13,8 @@ get_header(); ?>
<main id="main" class="site-main">
<?php
if ( have_posts() ) : ?>
if ( have_posts() ) :
?>
<header class="page-header">
<?php
@ -24,7 +25,8 @@ get_header(); ?>
<?php
/* Start the Loop */
while ( have_posts() ) : the_post();
while ( have_posts() ) :
the_post();
/*
* Include the Post-Format-specific template for the content.
@ -41,7 +43,8 @@ get_header(); ?>
get_template_part( 'template-parts/content', 'none' );
endif; ?>
endif;
?>
</main><!-- #main -->
</div><!-- #primary -->

15
comments.php

@ -24,7 +24,8 @@ if ( post_password_required() ) {
<?php
// You can start editing here -- including this comment!
if ( have_comments() ) : ?>
if ( have_comments() ) :
?>
<h2 class="comments-title">
<?php
$comment_count = get_comments_number();
@ -49,17 +50,21 @@ if ( post_password_required() ) {
<ol class="comment-list">
<?php
wp_list_comments( [
wp_list_comments(
[
'style' => 'ol',
'short_ping' => true,
] );
]
);
?>
</ol><!-- .comment-list -->
<?php the_comments_navigation();
<?php
the_comments_navigation();
// If comments are closed and there are comments, let's leave a little note, shall we?
if ( ! comments_open() ) : ?>
if ( ! comments_open() ) :
?>
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'pressbooks-aldine' ); ?></p>
<?php
endif;

8
composer.json

@ -17,6 +17,11 @@
"issues": "https://github.com/pressbooks/pressbooks-aldine/issues",
"forum": "https://discourse.pressbooks.org/"
},
"config": {
"platform": {
"php": "7.0.27"
}
},
"require": {
"php": ">=7",
"composer/installers": "~1.0",
@ -25,8 +30,7 @@
"spatie/color": "^1.1"
},
"require-dev": {
"humanmade/coding-standards": "^0.2.1",
"squizlabs/php_codesniffer": "^2.8.0",
"pressbooks/coding-standards": "dev-master",
"wpreadme2markdown/wp2md": "^3.0"
},
"scripts": {

179
composer.lock generated

@ -1,10 +1,10 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "edad2ef6112644b56c39a416914d8b0f",
"content-hash": "055e0d205a16f08b328ff9d4e80e0bcf",
"packages": [
{
"name": "composer/installers",
@ -262,27 +262,27 @@
"packages-dev": [
{
"name": "fig-r/psr2r-sniffer",
"version": "0.3.1",
"version": "0.5.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig-rectified/psr2r-sniffer.git",
"reference": "cdf61b2922efb225903e52c6222d7192d3b97ebf"
"reference": "ff4659fdb1ce8832a9e408a6e22aa05bc93efe10"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig-rectified/psr2r-sniffer/zipball/cdf61b2922efb225903e52c6222d7192d3b97ebf",
"reference": "cdf61b2922efb225903e52c6222d7192d3b97ebf",
"url": "https://api.github.com/repos/php-fig-rectified/psr2r-sniffer/zipball/ff4659fdb1ce8832a9e408a6e22aa05bc93efe10",
"reference": "ff4659fdb1ce8832a9e408a6e22aa05bc93efe10",
"shasum": ""
},
"require": {
"php": ">=5.4.16",
"squizlabs/php_codesniffer": "~2.3"
"squizlabs/php_codesniffer": "^3.0"
},
"bin": [
"bin/tokenize",
"bin/sniff"
],
"type": "library",
"type": "phpcodesniffer-standard",
"autoload": {
"psr-4": {
"PSR2R\\": "PSR2R"
@ -300,33 +300,70 @@
}
],
"description": "Code-Sniffer, Auto-Fixer and Tokenizer for PSR2-R",
"time": "2016-07-11T14:35:34+00:00"
"keywords": [
"codesniffer",
"cs"
],
"time": "2017-08-30T10:00:39+00:00"
},
{
"name": "humanmade/coding-standards",
"version": "0.2.2",
"version": "v0.5.0",
"source": {
"type": "git",
"url": "https://github.com/humanmade/coding-standards.git",
"reference": "f3974696bf139eb17049ae0ced114cbee1f86b20"
"reference": "b35747249bcc727a9eff22f746aaf9758d8a90ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/humanmade/coding-standards/zipball/f3974696bf139eb17049ae0ced114cbee1f86b20",
"reference": "f3974696bf139eb17049ae0ced114cbee1f86b20",
"url": "https://api.github.com/repos/humanmade/coding-standards/zipball/b35747249bcc727a9eff22f746aaf9758d8a90ce",
"reference": "b35747249bcc727a9eff22f746aaf9758d8a90ce",
"shasum": ""
},
"require": {
"fig-r/psr2r-sniffer": "^0.3.1",
"wp-coding-standards/wpcs": "^0.10.0"
"fig-r/psr2r-sniffer": "^0.5.0",
"squizlabs/php_codesniffer": "^3.1",
"wp-coding-standards/wpcs": "^0.14.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
},
"type": "project",
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0"
"GPL-2.0-or-later"
],
"description": "Human Made coding standards",
"time": "2017-08-31T03:33:08+00:00"
"time": "2018-05-22T13:24:47+00:00"
},
{
"name": "pressbooks/coding-standards",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/pressbooks/coding-standards.git",
"reference": "f09f0ba4dd3d20c2acb63c13b28a14bfe86ed229"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pressbooks/coding-standards/zipball/f09f0ba4dd3d20c2acb63c13b28a14bfe86ed229",
"reference": "f09f0ba4dd3d20c2acb63c13b28a14bfe86ed229",
"shasum": ""
},
"require": {
"fig-r/psr2r-sniffer": "0.5.0",
"humanmade/coding-standards": "0.5.0",
"squizlabs/php_codesniffer": "3.3.0"
},
"require-dev": {
"phpunit/phpunit": "6.5.8"
},
"type": "project",
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0-or-later"
],
"time": "2018-07-13T14:56:39+00:00"
},
{
"name": "psr/log",
@ -377,64 +414,37 @@
},
{
"name": "squizlabs/php_codesniffer",
"version": "2.9.1",
"version": "3.3.0",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "dcbed1074f8244661eecddfc2a675430d8d33f62"
"reference": "d86873af43b4aa9d1f39a3601cc0cfcf02b25266"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62",
"reference": "dcbed1074f8244661eecddfc2a675430d8d33f62",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d86873af43b4aa9d1f39a3601cc0cfcf02b25266",
"reference": "d86873af43b4aa9d1f39a3601cc0cfcf02b25266",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": ">=5.1.2"
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"bin": [
"scripts/phpcs",
"scripts/phpcbf"
"bin/phpcs",
"bin/phpcbf"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
"dev-master": "3.x-dev"
}
},
"autoload": {
"classmap": [
"CodeSniffer.php",
"CodeSniffer/CLI.php",
"CodeSniffer/Exception.php",
"CodeSniffer/File.php",
"CodeSniffer/Fixer.php",
"CodeSniffer/Report.php",
"CodeSniffer/Reporting.php",
"CodeSniffer/Sniff.php",
"CodeSniffer/Tokens.php",
"CodeSniffer/Reports/",
"CodeSniffer/Tokenizers/",
"CodeSniffer/DocGenerators/",
"CodeSniffer/Standards/AbstractPatternSniff.php",
"CodeSniffer/Standards/AbstractScopeSniff.php",
"CodeSniffer/Standards/AbstractVariableSniff.php",
"CodeSniffer/Standards/IncorrectPatternException.php",
"CodeSniffer/Standards/Generic/Sniffs/",
"CodeSniffer/Standards/MySource/Sniffs/",
"CodeSniffer/Standards/PEAR/Sniffs/",
"CodeSniffer/Standards/PSR1/Sniffs/",
"CodeSniffer/Standards/PSR2/Sniffs/",
"CodeSniffer/Standards/Squiz/Sniffs/",
"CodeSniffer/Standards/Zend/Sniffs/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
@ -451,20 +461,20 @@
"phpcs",
"standards"
],
"time": "2017-05-22T02:43:20+00:00"
"time": "2018-06-06T23:58:19+00:00"
},
{
"name": "symfony/console",
"version": "v3.4.3",
"version": "v3.4.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d"
"reference": "e54f84c50e3b12972e7750edfc5ca84b2284c44e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/8394c8ef121949e8f858f13bc1e34f05169e4e7d",
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d",
"url": "https://api.github.com/repos/symfony/console/zipball/e54f84c50e3b12972e7750edfc5ca84b2284c44e",
"reference": "e54f84c50e3b12972e7750edfc5ca84b2284c44e",
"shasum": ""
},
"require": {
@ -485,7 +495,7 @@
"symfony/process": "~3.3|~4.0"
},
"suggest": {
"psr/log": "For using the console logger",
"psr/log-implementation": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/lock": "",
"symfony/process": ""
@ -520,20 +530,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:37:34+00:00"
"time": "2018-07-10T14:02:11+00:00"
},
{
"name": "symfony/debug",
"version": "v3.4.3",
"version": "v3.4.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245"
"reference": "0e3ca9cbde90fffec8038f4d4e16fd4046bbd018"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/603b95dda8b00020e4e6e60dc906e7b715b1c245",
"reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245",
"url": "https://api.github.com/repos/symfony/debug/zipball/0e3ca9cbde90fffec8038f4d4e16fd4046bbd018",
"reference": "0e3ca9cbde90fffec8038f4d4e16fd4046bbd018",
"shasum": ""
},
"require": {
@ -576,20 +586,20 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T17:14:19+00:00"
"time": "2018-06-26T08:45:54+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.6.0",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296"
"reference": "3296adf6a6454a050679cde90f95350ad604b171"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171",
"reference": "3296adf6a6454a050679cde90f95350ad604b171",
"shasum": ""
},
"require": {
@ -601,7 +611,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6-dev"
"dev-master": "1.8-dev"
}
},
"autoload": {
@ -635,26 +645,30 @@
"portable",
"shim"
],
"time": "2017-10-11T12:05:26+00:00"
"time": "2018-04-26T10:06:28+00:00"
},
{
"name": "wp-coding-standards/wpcs",
"version": "0.10.0",
"version": "0.14.1",
"source": {
"type": "git",
"url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
"reference": "b39490465f6fd7375743a395019cd597e12119c9"
"reference": "cf6b310caad735816caef7573295f8a534374706"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/b39490465f6fd7375743a395019cd597e12119c9",
"reference": "b39490465f6fd7375743a395019cd597e12119c9",
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/cf6b310caad735816caef7573295f8a534374706",
"reference": "cf6b310caad735816caef7573295f8a534374706",
"shasum": ""
},
"require": {
"squizlabs/php_codesniffer": "^2.6"
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2"
},
"type": "library",
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
@ -671,7 +685,7 @@
"standards",
"wordpress"
],
"time": "2016-08-29T20:04:47+00:00"
"time": "2018-02-16T01:57:48+00:00"
},
{
"name": "wpreadme2markdown/wp2md",
@ -775,11 +789,16 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"pressbooks/coding-standards": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7"
},
"platform-dev": []
"platform-dev": [],
"platform-overrides": {
"php": "7.0.27"
}
}

12
footer.php

@ -20,9 +20,11 @@ $pb_network_contact_form = get_option( 'pb_network_contact_form' );
</div><!-- #content -->
<?php if ( $pb_network_contact_form ) :
<?php
if ( $pb_network_contact_form ) :
include( locate_template( 'partials/contact-form.php' ) );
endif; ?>
endif;
?>
<footer class="footer" role="contentinfo">
<div class="footer__inner">
@ -37,18 +39,22 @@ $pb_network_contact_form = get_option( 'pb_network_contact_form' );
<?php dynamic_sidebar( 'network-footer-block-2' ); ?>
<div class="social-media">
<?php if ( ! empty( $network_facebook ) ) { ?>
<?php /* translators: %s network name */ ?>
<a class="facebook" href="<?php echo $network_facebook; ?>" title="<?php printf( __( '%s on Facebook', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?>">
<svg class="icon--svg">
<use xlink:href="#facebook" />
</svg>
<?php /* translators: %s network name */ ?>
<span class="screen-reader-text"><?php printf( __( '%s on Facebook', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?></span>
</a>
<?php } ?>
<?php if ( ! empty( $network_twitter ) ) { ?>
<?php /* translators: %s network name */ ?>
<a class="twitter" href="<?php echo $network_twitter; ?>" title="<?php printf( __( '%s on Twitter', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?>">
<svg class="icon--svg">
<use xlink:href="#twitter" />
</svg>
<?php /* translators: %s network name */ ?>
<span class="screen-reader-text"><?php printf( __( '%s on Twitter', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?></span>
</a>
<?php } ?>
@ -67,6 +73,7 @@ $pb_network_contact_form = get_option( 'pb_network_contact_form' );
</svg>
</a>
<div class="footer__pressbooks__links">
<?php /* translators: %s Pressbooks */ ?>
<p class="footer__pressbooks__links__title"><a href="https://pressbooks.com"><?php printf( __( 'Powered by %s', 'pressbooks-aldine' ), '<span class="pressbooks">Pressbooks</span>' ); ?></a></p>
<ul class="footer__pressbooks__links__list">
<li><a href="https://pressbooks.org"><?php _e( 'Open Source', 'pressbooks-aldine' ); ?></a> |</li>
@ -88,7 +95,6 @@ $pb_network_contact_form = get_option( 'pb_network_contact_form' );
</svg>
<span class="screen-reader-text"><?php _e( 'Pressbooks on Twitter', 'pressbooks-aldine' ); ?></span></a>
</div>
</section>
</div><!-- .container -->
</footer><!-- .footer -->

6
functions.php

@ -13,11 +13,13 @@
if ( ! class_exists( 'Spatie\\Color\\Hex' ) ) {
$composer = get_template_directory() . '/vendor/autoload.php';
if ( ! file_exists( $composer ) ) {
wp_die( sprintf(
wp_die(
sprintf(
'<h1>%1$s</h1><p>%2$s</p>',
__( 'Dependencies Missing', 'pressbooks-aldine' ),
__( 'You must run <code>composer install</code> from the Aldine directory.', 'pressbooks-aldine' )
) );
)
);
}
require_once $composer;
}

22
header.php

@ -42,7 +42,8 @@
</svg>
<div id="page" class="site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'pressbooks-aldine' ); ?></a>
<header class="header" role="banner" style="background-image: url(<?php
<header class="header" role="banner" style="background-image: url(
<?php
if ( is_front_page() ) {
if ( has_header_image() ) {
echo( get_header_image() );
@ -51,18 +52,23 @@
}
} else {
echo get_template_directory_uri() . '/dist/images/catalog-header.jpg';
} ?>);">
}
?>
);">
<div class="header__inside">
<div class="header__brand">
<a title="<?php echo get_bloginfo( 'name', 'display' ); ?>" href="<?php echo network_home_url(); ?>">
<?php if ( has_custom_logo() ) { ?>
<?php $custom_logo_id = get_theme_mod( 'custom_logo' );
<?php
$custom_logo_id = get_theme_mod( 'custom_logo' );
printf(
'<img class="header__logo--img" src="%1$s" srcset="%2$s" alt="%3$s" />',
wp_get_attachment_image_src( $custom_logo_id, 'logo' )[0],
wp_get_attachment_image_srcset( $custom_logo_id, 'large' ),
/* translators: %s name of network */
sprintf( __( 'Logo for %s', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) )
); ?>
);
?>
<?php } else { ?>
<svg class="header__logo--svg">
<use xlink:href="#logo-pressbooks" />
@ -72,7 +78,9 @@
</div>
<div class="header__nav">
<a class="header__nav-icon js-header-nav-toggle" href="#navigation"><?php _e( 'Toggle Menu', 'pressbooks-aldine' ); ?><span class="header__nav-icon__icon"></span></a>
<?php wp_nav_menu( [
<?php
wp_nav_menu(
[
'theme_location' => 'primary-menu',
'fallback_cb' => '\Aldine\Helpers\default_menu',
'container' => 'nav',
@ -80,7 +88,9 @@
'container_id' => 'navigation',
'menu_id' => 'nav-primary-menu',
'menu_class' => 'nav--primary',
] ); ?>
]
);
?>
</div>
</div>
</header> <!-- .header -->

52
inc/actions/namespace.php

@ -6,10 +6,8 @@
namespace Aldine\Actions;
use Spatie\Color\Hex;
use Spatie\Color\Rgb;
use Spatie\Color\Rgba;
use PressbooksMix\Assets;
use Spatie\Color\Hex;
/**
* Sets up theme defaults and registers support for various WordPress features.
@ -44,30 +42,36 @@ function setup() {
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( [
register_nav_menus(
[
'primary-menu' => __( 'Primary Menu', 'pressbooks-aldine' ),
'network-footer-menu' => __( 'Footer Menu', 'pressbooks-aldine' ),
] );
]
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', [
add_theme_support(
'html5', [
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
] );
]
);
// Set up the WordPress core custom header feature.
add_theme_support( 'custom-header', [
add_theme_support(
'custom-header', [
'default-image' => get_template_directory_uri() . '/dist/images/header.jpg',
'width' => 1920,
'height' => 884,
'default-text-color' => '#000',
] );
]
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
@ -77,12 +81,14 @@ function setup() {
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', [
add_theme_support(
'custom-logo', [
'height' => 40,
'width' => 265,
'flex-width' => true,
'flex-height' => true,
] );
]
);
// Add editor style.
add_editor_style( $assets->getPath( 'styles/editor.css' ) );
@ -103,7 +109,8 @@ function widgets_init() {
'before_title' => '<h2>',
'after_title' => '</h2>',
];
register_sidebar( [
register_sidebar(
[
'name' => __( 'Network Footer Block 1', 'pressbooks-aldine' ),
'description' => __(
'Add content for your network&rsquo;s customizeable footer here.
@ -112,8 +119,10 @@ function widgets_init() {
'aldine'
),
'id' => 'network-footer-block-1',
] + $config );
register_sidebar( [
] + $config
);
register_sidebar(
[
'name' => __( 'Network Footer Block 2', 'pressbooks-aldine' ),
'description' => __(
'Add content for your network&rsquo;s customizeable footer here.
@ -122,7 +131,8 @@ function widgets_init() {
'aldine'
),
'id' => 'network-footer-block-2',
] + $config );
] + $config
);
}
/**
@ -216,15 +226,17 @@ function remove_admin_bar_callback() {
* Hide content editor for Catalog page.
*/
function hide_catalog_content_editor() {
$post_id = $_GET['post'] ?? null ;
$post_id = $_GET['post'] ?? null;
if ( ! isset( $post_id ) ) {
return;
}
$pagename = get_the_title( $post_id );
if ( $pagename === 'Catalog' ) {
add_action( 'edit_form_after_title', function() {
add_action(
'edit_form_after_title', function() {
printf( '<p>%s</p>', __( 'This page displays your network catalog, so there is no content to edit.', 'pressbooks-aldine' ) );
} );
}
);
remove_post_type_support( 'page', 'editor' );
remove_post_type_support( 'page', 'thumbnail' );
}
@ -272,7 +284,7 @@ function register_shortcode_buttons() {
* @since 1.1.0
*/
function tinymce_l18n() {
?>
?>
<script type='text/javascript'>
const aldine = {
page_section: {
@ -290,7 +302,7 @@ function tinymce_l18n() {
}
};
</script>
<?php
<?php
}
/**

11
inc/activation/namespace.php

@ -42,6 +42,7 @@ function create_default_content() {
__( 'designed PDF (for print-on-demand and digital distribution)', 'pressbooks-aldine' ),
__( 'Pressbooks is used by educational institutions around the world as well as authors and publishers.', 'pressbooks' ),
sprintf(
/* translators: %s link to about page */
__( 'For more information about Pressbooks, %s.', 'pressbooks-aldine' ),
sprintf( '<a href="https://pressbooks.com/about">%s</a>', __( 'see here', 'pressbooks-aldine' ) )
)
@ -55,6 +56,7 @@ function create_default_content() {
sprintf(
'<p>%1$s</p><p>%2$s</p>',
sprintf(
/* translators: %1$s: link to how to page; %2$s: link to guide */
__( 'The easiest way to get started with Pressbooks is to follow our %1$s. Or, you can review our %2$s.', 'pressbooks-aldine' ),
sprintf( '<a href="https://pressbooks.com/how-to-make-a-book-with-pressbooks">%s</a>', __( '4 Step Guide to Making a Book on Pressbooks', 'pressbooks-aldine' ) ),
sprintf( '<a href="https://guide.pressbooks.com/">%s</a>', __( 'Guide to Using Pressbooks', 'pressbooks-aldine' ) )
@ -79,7 +81,14 @@ function create_default_content() {
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' ] ) );
$pages[ $slug ] = wp_insert_post(
array_merge(
$page, [
'post_type' => 'page',
'post_status' => 'publish',
]
)
);
} else {
$pages[ $slug ] = $check->ID;
}

8
inc/admin/namespace.php

@ -70,7 +70,11 @@ function catalog_column( $column, $blog_id ) {
if ( 'in_catalog' === $column && ! is_main_site( $blog_id ) ) { ?>
<input class="in-catalog" type="checkbox" name="in_catalog" value="1" aria-label="<?php echo esc_attr_x( 'Show in Catalog', 'pressbooks-aldine' ); ?>" <?php checked( get_blog_option( $blog_id, \Aldine\Admin\BLOG_OPTION ), 1 ); ?> <?php
if ( ! get_blog_option( $blog_id, 'blog_public' ) ) { ?>disabled="disabled" title="<?php echo esc_attr_x( 'This book is private, so you can&rsquo;t display it in your catalog.', 'pressbooks-aldine' ); ?>"<?php } ?> />
<?php }
if ( ! get_blog_option( $blog_id, 'blog_public' ) ) {
?>
disabled="disabled" title="<?php echo esc_attr_x( 'This book is private, so you can&rsquo;t display it in your catalog.', 'pressbooks-aldine' ); ?>"<?php } ?> />
<?php
}
}

138
inc/customizer/namespace.php

@ -28,30 +28,38 @@ function customize_register( \WP_Customize_Manager $wp_customize ) {
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', [
$wp_customize->selective_refresh->add_partial(
'blogname', [
'selector' => '.site-title a',
'render_callback' => function() {
bloginfo( 'name' );
},
] );
$wp_customize->selective_refresh->add_partial( 'blogdescription', [
]
);
$wp_customize->selective_refresh->add_partial(
'blogdescription', [
'selector' => '.site-description',
'render_callback' => function() {
bloginfo( 'description' );
},
] );
$wp_customize->selective_refresh->add_partial( 'pb_front_page_catalog_title', [
]
);
$wp_customize->selective_refresh->add_partial(
'pb_front_page_catalog_title', [
'selector' => '#latest-books-title',
'render_callback' => function() {
get_option( 'pb_front_page_catalog_title' );
},
] );
$wp_customize->selective_refresh->add_partial( 'pb_network_contact_form_title', [
]
);
$wp_customize->selective_refresh->add_partial(
'pb_network_contact_form_title', [
'selector' => '#contact .contact__title',
'render_callback' => function() {
get_option( 'pb_network_contact_form_title' );
},
] );
]
);
}
foreach ( [
@ -92,11 +100,14 @@ function customize_register( \WP_Customize_Manager $wp_customize ) {
'description' => __( 'Used for text on an accent color background.', 'pressbooks-aldine' ),
],
] as $color ) {
$wp_customize->add_setting("pb_network_color_{$color['slug']}", [
$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->add_control(
new \WP_Customize_Color_Control(
$wp_customize,
"pb_network_color_{$color['slug']}",
[
@ -105,90 +116,125 @@ function customize_register( \WP_Customize_Manager $wp_customize ) {
'description' => $color['description'],
'settings' => "pb_network_color_{$color['slug']}",
]
));
)
);
}
$wp_customize->add_section('pb_network_social', [
$wp_customize->add_section(
'pb_network_social', [
'title' => __( 'Social Media', 'pressbooks-aldine' ),
'priority' => 30,
]);
$wp_customize->add_setting('pb_network_facebook', [
]
);
$wp_customize->add_setting(
'pb_network_facebook', [
'type' => 'option',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control('pb_network_facebook', [
]
);
$wp_customize->add_control(
'pb_network_facebook', [
'label' => __( 'Facebook', 'pressbooks-aldine' ),
'section' => 'pb_network_social',
'settings' => 'pb_network_facebook',
]);
$wp_customize->add_setting('pb_network_twitter', [
]
);
$wp_customize->add_setting(
'pb_network_twitter', [
'type' => 'option',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control('pb_network_twitter', [
]
);
$wp_customize->add_control(
'pb_network_twitter', [
'label' => __( 'Twitter', 'pressbooks-aldine' ),
'section' => 'pb_network_social',
'settings' => 'pb_network_twitter',
]);
]
);
if ( defined( 'PB_PLUGIN_VERSION' ) ) {
$wp_customize->add_section('pb_front_page_catalog', [
$wp_customize->add_section(
'pb_front_page_catalog', [
'title' => __( 'Front Page Catalog', 'pressbooks-aldine' ),
'priority' => 25,
]);
$wp_customize->add_setting('pb_front_page_catalog', [
]
);
$wp_customize->add_setting(
'pb_front_page_catalog', [
'type' => 'option',
]);
$wp_customize->add_control('pb_front_page_catalog', [
]
);
$wp_customize->add_control(
'pb_front_page_catalog', [
'label' => __( 'Show Front Page Catalog', 'pressbooks-aldine' ),
'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog',
'type' => 'checkbox',
]);
$wp_customize->add_setting('pb_front_page_catalog_title', [
]
);
$wp_customize->add_setting(
'pb_front_page_catalog_title', [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field',
'default' => __( 'Our Latest Titles', 'pressbooks-aldine' ),
]);
$wp_customize->add_control('pb_front_page_catalog_title', [
]
);
$wp_customize->add_control(
'pb_front_page_catalog_title', [
'label' => __( 'Front Page Catalog Title', 'pressbooks-aldine' ),
'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog_title',
]);
]
);
}
$wp_customize->add_section('pb_network_contact_form', [
$wp_customize->add_section(
'pb_network_contact_form', [
'title' => __( 'Contact Form', 'pressbooks-aldine' ),
'priority' => 25,
]);
$wp_customize->add_setting('pb_network_contact_form', [
]
);
$wp_customize->add_setting(
'pb_network_contact_form', [
'type' => 'option',
]);
$wp_customize->add_control('pb_network_contact_form', [
]
);
$wp_customize->add_control(
'pb_network_contact_form', [
'label' => __( 'Show Contact Form', 'pressbooks-aldine' ),
'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form',
'type' => 'checkbox',
]);
$wp_customize->add_setting('pb_network_contact_form_title', [
]
);
$wp_customize->add_setting(
'pb_network_contact_form_title', [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field',
'default' => __( 'Contact Us', 'pressbooks-aldine' ),
]);
$wp_customize->add_control('pb_network_contact_form_title', [
]
);
$wp_customize->add_control(
'pb_network_contact_form_title', [
'label' => __( 'Contact Form Title', 'pressbooks-aldine' ),
'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form_title',
]);
$wp_customize->add_setting('pb_network_contact_email', [
]
);
$wp_customize->add_setting(
'pb_network_contact_email', [
'type' => 'option',
'default' => get_option( 'admin_email', '' ),
'sanitize_callback' => 'sanitize_email',
]);
$wp_customize->add_control('pb_network_contact_email', [
]
);
$wp_customize->add_control(
'pb_network_contact_email', [
'label' => __( 'Contact Email', 'pressbooks-aldine' ),
'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_email',
]);
]
);
}
/**

8
inc/filters/namespace.php

@ -7,8 +7,8 @@
namespace Aldine\Filters;
use PressbooksMix\Assets;
use function Aldine\Helpers\has_sections;
use PressbooksMix\Assets;
/**
* Adds custom classes to the array of body classes.
@ -32,9 +32,11 @@ function body_classes( array $classes ) {
}
/** Clean up class names for custom templates */
$classes = array_map( function ( $class ) {
$classes = array_map(
function ( $class ) {
return preg_replace( [ '/-php$/', '/^page-template-views/' ], '', $class );
}, $classes );
}, $classes
);
return array_filter( $classes );
}

19
inc/helpers/namespace.php

@ -7,8 +7,8 @@
namespace Aldine\Helpers;
use Pressbooks\Book;
use function \Pressbooks\Metadata\book_information_to_schema;
use Pressbooks\Book;
/**
* @param int $page
@ -22,7 +22,10 @@ use function \Pressbooks\Metadata\book_information_to_schema;
function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $license = '', $subject = '' ) {
if ( ! defined( 'PB_PLUGIN_VERSION' ) ) {
return [ 'pages' => 0, 'books' => [] ]; // Bail
return [
'pages' => 0,
'books' => [],
]; // Bail
}
/**
@ -91,7 +94,10 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen
}
}
return [ 'pages' => $total_pages, 'books' => $books ];
return [
'pages' => $total_pages,
'books' => $books,
];
}
@ -226,9 +232,11 @@ function default_menu( $args = [], $items = '' ) {
get_default_menu( $items )
);
if ( class_exists( '\PressbooksOAuth\OAuth' ) ) {
add_filter( 'pb_oauth_output_button', function( $bool ) {
add_filter(
'pb_oauth_output_button', function( $bool ) {
return false;
} );
}
);
do_action( 'pressbooks_oauth_connect' );
}
}
@ -279,6 +287,7 @@ function handle_contact_form_submission() {
} else {
$sent = wp_mail(
$contact_email,
/* translators: %s name of contact for submitter */
sprintf( __( 'Contact Form Submission from %s', 'pressbooks-aldine' ), $name ),
sprintf(
"From: %1\$s <%2\$s>\nInstitution: %3\$s\n\n%4\$s",

12
inc/intervention.php

@ -11,15 +11,18 @@ intervention( 'remove-customizer-items', 'static-front-page', 'all' );
intervention( 'remove-emoji' );
intervention( 'remove-howdy', __( 'Hello,', 'pressbooks-aldine' ) );
intervention( 'remove-dashboard-items', [ 'activity', 'quick-draft' ] );
intervention( 'remove-menu-items', [
intervention(
'remove-menu-items', [
'posts',
'tool-import',
'tool-export',
'setting-writing',
'setting-reading',
'setting-permalink',
], 'all' );
intervention( 'remove-widgets', [
], 'all'
);
intervention(
'remove-widgets', [
'pages',
'calendar',
'archives',
@ -36,5 +39,6 @@ intervention( 'remove-widgets', [
'custom-html',
'media-video',
'akismet',
], 'all' );
], 'all'
);
intervention( 'remove-toolbar-frontend', 'all' );

9
index.php

@ -20,7 +20,8 @@ get_header(); ?>
<?php
if ( have_posts() ) :
if ( is_home() && ! is_front_page() ) : ?>
if ( is_home() && ! is_front_page() ) :
?>
<header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header>
@ -29,7 +30,8 @@ get_header(); ?>
endif;
/* Start the Loop */
while ( have_posts() ) : the_post();
while ( have_posts() ) :
the_post();
/*
* Include the Post-Format-specific template for the content.
@ -46,7 +48,8 @@ get_header(); ?>
get_template_part( 'template-parts/content', 'none' );
endif; ?>
endif;
?>
</main><!-- #main -->
</div><!-- #primary -->

10
page-catalog.php

@ -9,10 +9,10 @@
* @package Aldine
*/
use function Aldine\Helpers\get_available_licenses;
use function Aldine\Helpers\get_available_subjects;
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';
@ -38,9 +38,9 @@ if ( ! empty( $catalog_data['books'] ) ) :
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
<?php
get_sidebar();
get_footer();
else :
global $wp_query;

9
page.php

@ -17,9 +17,11 @@ get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php if ( is_front_page() ) :
<?php
if ( is_front_page() ) :
while ( have_posts() ) : the_post();
while ( have_posts() ) :
the_post();
get_template_part( 'partials/content', 'front-page' );
@ -27,7 +29,8 @@ get_header(); ?>
else :
while ( have_posts() ) : the_post();
while ( have_posts() ) :
the_post();
get_template_part( 'partials/content', 'page' );

19
partials/book.php

@ -1,23 +1,32 @@
<?php use function \Aldine\Helpers\maybe_truncate_string; ?>
<?php $subject = ( isset( $book['subject'] ) ) ? substr( $book['subject'], 0, 2 ) : '';
<?php
$subject = ( isset( $book['subject'] ) ) ? substr( $book['subject'], 0, 2 ) : '';
$date = ( isset( $book['metadata']['datePublished'] ) ) ? str_replace( '-', '', $book['metadata']['datePublished'] ) : '';
?>
<li class="book"
<?php if ( $date ) { ?>data-date-published="<?php echo $date; ?>"<?php } ?>
<?php
if ( $date ) {
?>
data-date-published="<?php echo $date; ?>"<?php } ?>
data-license="<?php echo ( new \Pressbooks\Licensing() )->getLicenseFromUrl( $book['metadata']['license']['url'] ); ?>"
<?php if ( ! empty( $subject ) ) { ?> data-subject="<?php echo $subject ?>"<?php } ?>
<?php
if ( ! empty( $subject ) ) {
?>
data-subject="<?php echo $subject ?>"<?php } ?>
>
<p class="book__title">
<a href="<?php echo $book['link']; ?>"><?php echo maybe_truncate_string( $book['metadata']['name'] ); ?></a>
</p>
<?php /* <?php if (isset( $book['metadata']['author'] ) ) { ?>
<?php
/* <?php if (isset( $book['metadata']['author'] ) ) { ?>
<p class="book__author">
<?php _e( 'By', 'pressbooks-aldine' ); ?> <?php foreach ( $book['metadata']['author'] as $author ) {
echo $author['name'];
} ?>
</p>
<?php } ?> */ ?>
<?php } ?> */
?>
<?php if ( ! empty( $subject ) ) { ?>
<p class="book__subject">
<a href="<?php echo network_home_url( "/catalog/#$subject" ) ?>"><?php echo \Pressbooks\Metadata\get_subject_from_thema( $book['subject'] ); ?></a>

48
partials/contact-form.php

@ -23,33 +23,65 @@ $contact_form_response = \Aldine\Helpers\handle_contact_form_submission();
<?php wp_nonce_field( 'pb_root_contact_form', 'pb_root_contact_form_nonce' ); ?>
<input type="hidden" name="submitted" value="1">
<p class="form__row">
<input id="contact-name" <?php if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_name' ) : ?>class="error"<?php endif; ?> type="text" name="visitor_name" value="<?php if ( $contact_form_response['status'] === 'error' ) :
<input id="contact-name"
<?php
if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_name' ) :
?>
class="error"<?php endif; ?> type="text" name="visitor_name" value="
<?php
if ( $contact_form_response['status'] === 'error' ) :
echo $contact_form_response['values']['visitor_name'];
endif; ?>" required>
endif;
?>
" required>
<label for="contact-name">
<?php _e( 'Your name (required)', 'pressbooks-aldine' ); ?>
</label>
</p>
<p class="form__row">
<input id="contact-email" <?php if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_email' ) : ?>class="error" <?php endif; ?>type="email" name="visitor_email" value="<?php if ( $contact_form_response['status'] === 'error' ) :
<input id="contact-email"
<?php
if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_email' ) :
?>
class="error" <?php endif; ?>type="email" name="visitor_email" value="
<?php
if ( $contact_form_response['status'] === 'error' ) :
echo $contact_form_response['values']['visitor_email'];
endif; ?>" required>
endif;
?>
" required>
<label for="contact-email">
<?php _e( 'Your email address (required)', 'pressbooks-aldine' ); ?>
</label>
</p>
<p class="form__row">
<input id="contact-institution" <?php if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_institution' ) : ?>class="error" <?php endif; ?>type="text" name="visitor_institution" value="<?php if ( $contact_form_response['status'] === 'error' ) :
<input id="contact-institution"
<?php
if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_institution' ) :
?>
class="error" <?php endif; ?>type="text" name="visitor_institution" value="
<?php
if ( $contact_form_response['status'] === 'error' ) :
echo $contact_form_response['values']['visitor_institution'];
endif; ?>" required>
endif;
?>
" required>
<label for="contact-institution">
<?php _e( 'Your institution (required)', 'pressbooks-aldine' ); ?>
</label>
</p>
<p class="form__row">
<textarea id="contact-message" <?php if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'message' ) : ?>class="error" <?php endif; ?>name="message" required><?php if ( $contact_form_response['status'] === 'error' ) :
<textarea id="contact-message"
<?php
if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'message' ) :
?>
class="error" <?php endif; ?>name="message" required>
<?php
if ( $contact_form_response['status'] === 'error' ) :
echo $contact_form_response['values']['message'];
endif; ?></textarea>
endif;
?>
</textarea>
<label for="contact-message">
<?php _e( 'Your message (required)', 'pressbooks-aldine' ); ?>
</label>

17
partials/content-front-page.php

@ -55,13 +55,22 @@ if ( get_option( 'pb_front_page_catalog' ) ) {
<?php if ( get_option( 'pb_front_page_catalog' ) && ! empty( $catalog_data['books'] ) ) : ?>
<div id="latest-books" class="latest-books">
<h2 id="latest-books-title"><?php echo $latest_books_title; ?></h2>
<div class="slider" role="region" aria-labelledby="latest-books-title" data-total-pages="<?php echo $catalog_data['pages']; ?>" <?php if ( $next_page <= $catalog_data['pages'] ) : ?>data-next-page="<?php echo $next_page; ?>"<?php endif; ?>>
<div class="slider" role="region" aria-labelledby="latest-books-title" data-total-pages="<?php echo $catalog_data['pages']; ?>"
<?php
if ( $next_page <= $catalog_data['pages'] ) :
?>
data-next-page="<?php echo $next_page; ?>"<?php endif; ?>>
<ul class="books">
<?php foreach ( $catalog_data['books'] as $book ) :
<?php
foreach ( $catalog_data['books'] as $book ) :
include( locate_template( 'partials/book.php' ) );
endforeach; ?>
endforeach;
?>
</ul>
<?php if ( $previous_page || $next_page ) { include( locate_template( 'partials/paged-navigation.php' ) ); } ?>
<?php
if ( $previous_page || $next_page ) {
include( locate_template( 'partials/paged-navigation.php' ) ); }
?>
</div>
<p class="catalog-link">
<a class="call-to-action" href="<?php echo network_home_url( '/catalog/' ); ?>"><?php _e( 'View Complete Catalog', 'pressbooks-aldine' ); ?></a>

15
partials/content-none.php

@ -16,9 +16,11 @@
<div class="page-content">
<?php
if ( is_home() && current_user_can( 'publish_posts' ) ) : ?>
if ( is_home() && current_user_can( 'publish_posts' ) ) :
?>
<p><?php
<p>
<?php
printf(
wp_kses(
/* translators: 1: link to WP admin new post page. */
@ -31,7 +33,8 @@
),
esc_url( admin_url( 'post-new.php' ) )
);
?></p>
?>
</p>
<?php elseif ( is_search() ) : ?>
@ -39,12 +42,14 @@
<?php
get_search_form();
else : ?>
else :
?>
<p><?php esc_html_e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', 'pressbooks-aldine' ); ?></p>
<?php
get_search_form();
endif; ?>
endif;
?>
</div><!-- .page-content -->
</section><!-- .no-results -->

49
partials/content-page-catalog.php

@ -18,11 +18,15 @@
<input type="radio" name="subject" id="all-subjects" value="" <?php checked( $subject, '' ); ?>>
<label for="all-subjects"><?php _e( 'All Subjects', 'pressbooks-aldine' ); ?> <svg class="checked"><use xlink:href="#checkmark" /></svg></label>
<div class="subject-groups">
<?php foreach ( $subjects as $key => $val ) :
if ( array_key_exists( $key, $available_subjects ) ) : ?>
<?php
foreach ( $subjects as $key => $val ) :
if ( array_key_exists( $key, $available_subjects ) ) :
?>
<h3><span class="label"><?php echo $val['label']; ?></span></h3>
<?php foreach ( $val['children'] as $k => $v ) :
if ( in_array( $k, $available_subjects[ $key ], true ) ) : ?>
<?php
foreach ( $val['children'] as $k => $v ) :
if ( in_array( $k, $available_subjects[ $key ], true ) ) :
?>
<input type="radio" name="subject" id="<?php echo $k; ?>" value="<?php echo $k; ?>" <?php checked( $subject, $k ); ?>>
<label for="<?php echo $k; ?>"><span class="label"><?php echo $v; ?></span> <svg class="checked"><use xlink:href="#checkmark" /></svg></label>
<?php endif; ?>
@ -35,12 +39,16 @@
<h2><?php _e( 'Filter by License', 'pressbooks-aldine' ); ?></h2>
<input type="radio" name="license" id="all-licenses" value="" <?php checked( $license, '' ); ?>>
<label for="all-licenses"><?php _e( 'All Licenses', 'pressbooks-aldine' ); ?> <svg class="checked"><use xlink:href="#checkmark" /></svg></label>
<?php foreach ( $licenses as $key => $value ) :
if ( in_array( $key, $available_licenses, true ) ) : ?>
<?php
foreach ( $licenses as $key => $value ) :
if ( in_array( $key, $available_licenses, true ) ) :
?>
<input type="radio" name="license" id="<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( $license, $key ); ?>>
<label for="<?php echo $key; ?>"><?php echo $value; ?> <svg class="checked"><use xlink:href="#checkmark" /></svg></label>
<?php endif;
endforeach; ?>
<?php
endif;
endforeach;
?>
</fieldset>
<fieldset class="sorts">
<h2><?php _e( 'Sort by', 'pressbooks-aldine' ); ?></h2>
@ -50,7 +58,8 @@
'subject' => __( 'Subject', 'pressbooks-aldine' ),
'latest' => __( 'Latest', 'pressbooks-aldine' ),
];
foreach ( $sorts as $key => $value ) { ?>
foreach ( $sorts as $key => $value ) {
?>
<input type="radio" name="orderby" id="<?php echo $key ?>" value="<?php echo $key ?>" <?php checked( $orderby, $key ); ?>>
<label for="<?php echo $key ?>"><?php echo $value; ?> <svg class="checked"><use xlink:href="#checkmark" /></svg></label>
<?php } ?>
@ -59,26 +68,36 @@
<button type="submit"><?php _e( 'Submit', 'pressbooks-aldine' ); ?></button>
</form>
<ul class="books">
<?php foreach ( $catalog_data['books'] as $book ) :
<?php
foreach ( $catalog_data['books'] as $book ) :
include( locate_template( 'partials/book.php' ) );
endforeach; ?>
endforeach;
?>
</ul>
<?php if ( $catalog_data['pages'] > 1 ) : ?>
<nav class="catalog-navigation">
<?php if ( $previous_page ) : ?><a class="previous" rel="previous" data-page="<?php echo $previous_page; ?>" href="<?php echo network_home_url( "/catalog/page/$previous_page/" ); ?>"><span class="screen-reader-text"><?php _e( 'Previous Page', 'pressbooks' ); ?></span>
<?php
if ( $previous_page ) :
?>
<a class="previous" rel="previous" data-page="<?php echo $previous_page; ?>" href="<?php echo network_home_url( "/catalog/page/$previous_page/" ); ?>"><span class="screen-reader-text"><?php _e( 'Previous Page', 'pressbooks' ); ?></span>
<svg aria-hidden="true">
<use xlink:href="#arrow-left" />
</svg></a><?php endif; ?>
<div class="pages">
<?php for ( $i = 1; $i <= $catalog_data['pages']; $i++ ) :
if ( $i === $current_page ) : ?>
<?php
for ( $i = 1; $i <= $catalog_data['pages']; $i++ ) :
if ( $i === $current_page ) :
?>
<span class="current"><?php echo $i; ?></span>
<?php else : ?>
<a href="<?php echo network_home_url( "/catalog/page/$i/" ); ?>"><?php echo $i; ?></a>
<?php endif; ?>
<?php endfor; ?>
</div>
<?php if ( $next_page <= $catalog_data['pages'] ) : ?><a class="next" rel="next" data-page="<?php echo $next_page; ?>" href="<?php echo network_home_url( "/catalog/page/$next_page/" ); ?>"><span class="screen-reader-text"><?php _e( 'Next Page', 'pressbooks' ); ?></span>
<?php
if ( $next_page <= $catalog_data['pages'] ) :
?>
<a class="next" rel="next" data-page="<?php echo $next_page; ?>" href="<?php echo network_home_url( "/catalog/page/$next_page/" ); ?>"><span class="screen-reader-text"><?php _e( 'Next Page', 'pressbooks' ); ?></span>
<svg aria-hidden="true">
<use xlink:href="#arrow-right" />
</svg></a><?php endif; ?>

6
partials/content-page.php

@ -18,10 +18,12 @@
<?php
the_content();
wp_link_pages( [
wp_link_pages(
[
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'pressbooks-aldine' ),
'after' => '</div>',
] );
]
);
?>
</div><!-- .entry-content -->

18
partials/content.php

@ -18,17 +18,20 @@
the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
endif;
if ( 'post' === get_post_type() ) : ?>
if ( 'post' === get_post_type() ) :
?>
<div class="entry-meta">
<?php pressbooks_aldine_posted_on(); ?>
</div><!-- .entry-meta -->
<?php
endif; ?>
endif;
?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php
the_content( sprintf(
the_content(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'pressbooks-aldine' ),
@ -39,12 +42,15 @@
]
),
get_the_title()
) );
)
);
wp_link_pages( [
wp_link_pages(
[
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'pressbooks-aldine' ),
'after' => '</div>',
] );
]
);
?>
</div><!-- .entry-content -->

40
phpcs.ruleset.xml

@ -1,41 +1,13 @@
<?xml version="1.0"?>
<ruleset>
<!-- Scan only PHP files -->
<arg name="extensions" value="php"/>
<!-- Use Pressbooks Coding Standards -->
<rule ref="vendor/pressbooks/coding-standards" />
<!-- Show colors in console -->
<arg value="-colors"/>
<!-- Show progress -->
<arg value="p"/>
<!-- Be quiet -->
<arg value="q"/>
<!-- Use HM Coding Standards -->
<rule ref="vendor/humanmade/coding-standards">
<!-- Disable all ESLint checks -->
<exclude name="HM.Debug.ESLint"/>
<!-- Disable rules Pressbooks disagrees with -->
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
<exclude name="WordPress.NamingConventions.ValidVariableName.MemberNotSnakeCase"/>
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar"/>
<exclude name="WordPress.VIP.SessionVariableUsage"/>
<exclude name="WordPress.VIP.SessionFunctionsUsage"/>
<!-- Disable LayoutOrder until humanmade/coding-standards#5 is fixed -->
<exclude name="HM.Layout.Order.WrongOrder"/>
</rule>
<!-- Re-enable rules Pressbooks agrees with -->
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<!-- Disable Side Effects rule for functions.php -->
<!-- Disable Side Effects and MissingNamespace rules for bootstrapping files: -->
<rule ref="PSR1.Files.SideEffects">
<exclude-pattern>functions.php</exclude-pattern>
<exclude-pattern>/functions.php</exclude-pattern>
</rule>
<!-- Disable Namespaced Functions for functions.php -->
<rule ref="HM.Functions.NamespacedFunctions">
<exclude-pattern>functions.php</exclude-pattern>
<rule ref="HM.Functions.NamespacedFunctions.MissingNamespace">
<exclude-pattern>/functions.php</exclude-pattern>
</rule>
</ruleset>

15
search.php

@ -13,18 +13,22 @@ get_header(); ?>
<main id="main" class="site-main">
<?php
if ( have_posts() ) : ?>
if ( have_posts() ) :
?>
<header class="page-header">
<h1 class="page-title"><?php
<h1 class="page-title">
<?php
/* translators: %s: search query. */
printf( esc_html__( 'Search Results for: %s', 'pressbooks-aldine' ), '<span>' . get_search_query() . '</span>' );
?></h1>
?>
</h1>
</header><!-- .page-header -->
<?php
/* Start the Loop */
while ( have_posts() ) : the_post();
while ( have_posts() ) :
the_post();
/**
* Run the loop for the search to output the results.
@ -41,7 +45,8 @@ get_header(); ?>
get_template_part( 'template-parts/content', 'none' );
endif; ?>
endif;
?>
</main><!-- #main -->
</section><!-- #primary -->

3
single.php

@ -13,7 +13,8 @@ get_header(); ?>
<main id="main" class="site-main">
<?php
while ( have_posts() ) : the_post();
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', get_post_type() );

Loading…
Cancel
Save