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

15
comments.php

@ -24,7 +24,8 @@ if ( post_password_required() ) {
<?php <?php
// You can start editing here -- including this comment! // You can start editing here -- including this comment!
if ( have_comments() ) : ?> if ( have_comments() ) :
?>
<h2 class="comments-title"> <h2 class="comments-title">
<?php <?php
$comment_count = get_comments_number(); $comment_count = get_comments_number();
@ -49,17 +50,21 @@ if ( post_password_required() ) {
<ol class="comment-list"> <ol class="comment-list">
<?php <?php
wp_list_comments( [ wp_list_comments(
[
'style' => 'ol', 'style' => 'ol',
'short_ping' => true, 'short_ping' => true,
] ); ]
);
?> ?>
</ol><!-- .comment-list --> </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 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> <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'pressbooks-aldine' ); ?></p>
<?php <?php
endif; endif;

8
composer.json

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

179
composer.lock generated

@ -1,10 +1,10 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "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" "This file is @generated automatically"
], ],
"content-hash": "edad2ef6112644b56c39a416914d8b0f", "content-hash": "055e0d205a16f08b328ff9d4e80e0bcf",
"packages": [ "packages": [
{ {
"name": "composer/installers", "name": "composer/installers",
@ -262,27 +262,27 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "fig-r/psr2r-sniffer", "name": "fig-r/psr2r-sniffer",
"version": "0.3.1", "version": "0.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig-rectified/psr2r-sniffer.git", "url": "https://github.com/php-fig-rectified/psr2r-sniffer.git",
"reference": "cdf61b2922efb225903e52c6222d7192d3b97ebf" "reference": "ff4659fdb1ce8832a9e408a6e22aa05bc93efe10"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig-rectified/psr2r-sniffer/zipball/cdf61b2922efb225903e52c6222d7192d3b97ebf", "url": "https://api.github.com/repos/php-fig-rectified/psr2r-sniffer/zipball/ff4659fdb1ce8832a9e408a6e22aa05bc93efe10",
"reference": "cdf61b2922efb225903e52c6222d7192d3b97ebf", "reference": "ff4659fdb1ce8832a9e408a6e22aa05bc93efe10",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.4.16", "php": ">=5.4.16",
"squizlabs/php_codesniffer": "~2.3" "squizlabs/php_codesniffer": "^3.0"
}, },
"bin": [ "bin": [
"bin/tokenize", "bin/tokenize",
"bin/sniff" "bin/sniff"
], ],
"type": "library", "type": "phpcodesniffer-standard",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"PSR2R\\": "PSR2R" "PSR2R\\": "PSR2R"
@ -300,33 +300,70 @@
} }
], ],
"description": "Code-Sniffer, Auto-Fixer and Tokenizer for PSR2-R", "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", "name": "humanmade/coding-standards",
"version": "0.2.2", "version": "v0.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/humanmade/coding-standards.git", "url": "https://github.com/humanmade/coding-standards.git",
"reference": "f3974696bf139eb17049ae0ced114cbee1f86b20" "reference": "b35747249bcc727a9eff22f746aaf9758d8a90ce"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/humanmade/coding-standards/zipball/f3974696bf139eb17049ae0ced114cbee1f86b20", "url": "https://api.github.com/repos/humanmade/coding-standards/zipball/b35747249bcc727a9eff22f746aaf9758d8a90ce",
"reference": "f3974696bf139eb17049ae0ced114cbee1f86b20", "reference": "b35747249bcc727a9eff22f746aaf9758d8a90ce",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"fig-r/psr2r-sniffer": "^0.3.1", "fig-r/psr2r-sniffer": "^0.5.0",
"wp-coding-standards/wpcs": "^0.10.0" "squizlabs/php_codesniffer": "^3.1",
"wp-coding-standards/wpcs": "^0.14.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
}, },
"type": "project", "type": "project",
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"GPL-2.0" "GPL-2.0-or-later"
], ],
"description": "Human Made coding standards", "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", "name": "psr/log",
@ -377,64 +414,37 @@
}, },
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "2.9.1", "version": "3.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" "reference": "d86873af43b4aa9d1f39a3601cc0cfcf02b25266"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62", "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d86873af43b4aa9d1f39a3601cc0cfcf02b25266",
"reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", "reference": "d86873af43b4aa9d1f39a3601cc0cfcf02b25266",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-simplexml": "*", "ext-simplexml": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"php": ">=5.1.2" "php": ">=5.4.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0" "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
}, },
"bin": [ "bin": [
"scripts/phpcs", "bin/phpcs",
"scripts/phpcbf" "bin/phpcbf"
], ],
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "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/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"BSD-3-Clause" "BSD-3-Clause"
@ -451,20 +461,20 @@
"phpcs", "phpcs",
"standards" "standards"
], ],
"time": "2017-05-22T02:43:20+00:00" "time": "2018-06-06T23:58:19+00:00"
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v3.4.3", "version": "v3.4.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d" "reference": "e54f84c50e3b12972e7750edfc5ca84b2284c44e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/8394c8ef121949e8f858f13bc1e34f05169e4e7d", "url": "https://api.github.com/repos/symfony/console/zipball/e54f84c50e3b12972e7750edfc5ca84b2284c44e",
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d", "reference": "e54f84c50e3b12972e7750edfc5ca84b2284c44e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -485,7 +495,7 @@
"symfony/process": "~3.3|~4.0" "symfony/process": "~3.3|~4.0"
}, },
"suggest": { "suggest": {
"psr/log": "For using the console logger", "psr/log-implementation": "For using the console logger",
"symfony/event-dispatcher": "", "symfony/event-dispatcher": "",
"symfony/lock": "", "symfony/lock": "",
"symfony/process": "" "symfony/process": ""
@ -520,20 +530,20 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2018-01-03T07:37:34+00:00" "time": "2018-07-10T14:02:11+00:00"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v3.4.3", "version": "v3.4.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
"reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245" "reference": "0e3ca9cbde90fffec8038f4d4e16fd4046bbd018"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/603b95dda8b00020e4e6e60dc906e7b715b1c245", "url": "https://api.github.com/repos/symfony/debug/zipball/0e3ca9cbde90fffec8038f4d4e16fd4046bbd018",
"reference": "603b95dda8b00020e4e6e60dc906e7b715b1c245", "reference": "0e3ca9cbde90fffec8038f4d4e16fd4046bbd018",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -576,20 +586,20 @@
], ],
"description": "Symfony Debug Component", "description": "Symfony Debug Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2018-01-03T17:14:19+00:00" "time": "2018-06-26T08:45:54+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.6.0", "version": "v1.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" "reference": "3296adf6a6454a050679cde90f95350ad604b171"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171",
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", "reference": "3296adf6a6454a050679cde90f95350ad604b171",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -601,7 +611,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.6-dev" "dev-master": "1.8-dev"
} }
}, },
"autoload": { "autoload": {
@ -635,26 +645,30 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2017-10-11T12:05:26+00:00" "time": "2018-04-26T10:06:28+00:00"
}, },
{ {
"name": "wp-coding-standards/wpcs", "name": "wp-coding-standards/wpcs",
"version": "0.10.0", "version": "0.14.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
"reference": "b39490465f6fd7375743a395019cd597e12119c9" "reference": "cf6b310caad735816caef7573295f8a534374706"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/b39490465f6fd7375743a395019cd597e12119c9", "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/cf6b310caad735816caef7573295f8a534374706",
"reference": "b39490465f6fd7375743a395019cd597e12119c9", "reference": "cf6b310caad735816caef7573295f8a534374706",
"shasum": "" "shasum": ""
}, },
"require": { "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/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
@ -671,7 +685,7 @@
"standards", "standards",
"wordpress" "wordpress"
], ],
"time": "2016-08-29T20:04:47+00:00" "time": "2018-02-16T01:57:48+00:00"
}, },
{ {
"name": "wpreadme2markdown/wp2md", "name": "wpreadme2markdown/wp2md",
@ -775,11 +789,16 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {
"pressbooks/coding-standards": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": ">=7" "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 --> </div><!-- #content -->
<?php if ( $pb_network_contact_form ) : <?php
if ( $pb_network_contact_form ) :
include( locate_template( 'partials/contact-form.php' ) ); include( locate_template( 'partials/contact-form.php' ) );
endif; ?> endif;
?>
<footer class="footer" role="contentinfo"> <footer class="footer" role="contentinfo">
<div class="footer__inner"> <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' ); ?> <?php dynamic_sidebar( 'network-footer-block-2' ); ?>
<div class="social-media"> <div class="social-media">
<?php if ( ! empty( $network_facebook ) ) { ?> <?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' ) ); ?>"> <a class="facebook" href="<?php echo $network_facebook; ?>" title="<?php printf( __( '%s on Facebook', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?>">
<svg class="icon--svg"> <svg class="icon--svg">
<use xlink:href="#facebook" /> <use xlink:href="#facebook" />
</svg> </svg>
<?php /* translators: %s network name */ ?>
<span class="screen-reader-text"><?php printf( __( '%s on Facebook', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?></span> <span class="screen-reader-text"><?php printf( __( '%s on Facebook', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?></span>
</a> </a>
<?php } ?> <?php } ?>
<?php if ( ! empty( $network_twitter ) ) { ?> <?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' ) ); ?>"> <a class="twitter" href="<?php echo $network_twitter; ?>" title="<?php printf( __( '%s on Twitter', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?>">
<svg class="icon--svg"> <svg class="icon--svg">
<use xlink:href="#twitter" /> <use xlink:href="#twitter" />
</svg> </svg>
<?php /* translators: %s network name */ ?>
<span class="screen-reader-text"><?php printf( __( '%s on Twitter', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?></span> <span class="screen-reader-text"><?php printf( __( '%s on Twitter', 'pressbooks-aldine' ), get_bloginfo( 'name', 'display' ) ); ?></span>
</a> </a>
<?php } ?> <?php } ?>
@ -67,6 +73,7 @@ $pb_network_contact_form = get_option( 'pb_network_contact_form' );
</svg> </svg>
</a> </a>
<div class="footer__pressbooks__links"> <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> <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"> <ul class="footer__pressbooks__links__list">
<li><a href="https://pressbooks.org"><?php _e( 'Open Source', 'pressbooks-aldine' ); ?></a> |</li> <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> </svg>
<span class="screen-reader-text"><?php _e( 'Pressbooks on Twitter', 'pressbooks-aldine' ); ?></span></a> <span class="screen-reader-text"><?php _e( 'Pressbooks on Twitter', 'pressbooks-aldine' ); ?></span></a>
</div> </div>
</section> </section>
</div><!-- .container --> </div><!-- .container -->
</footer><!-- .footer --> </footer><!-- .footer -->

6
functions.php

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

22
header.php

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

52
inc/actions/namespace.php

@ -6,10 +6,8 @@
namespace Aldine\Actions; namespace Aldine\Actions;
use Spatie\Color\Hex;
use Spatie\Color\Rgb;
use Spatie\Color\Rgba;
use PressbooksMix\Assets; use PressbooksMix\Assets;
use Spatie\Color\Hex;
/** /**
* Sets up theme defaults and registers support for various WordPress features. * Sets up theme defaults and registers support for various WordPress features.
@ -44,30 +42,36 @@ function setup() {
add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in two locations. // This theme uses wp_nav_menu() in two locations.
register_nav_menus( [ register_nav_menus(
[
'primary-menu' => __( 'Primary Menu', 'pressbooks-aldine' ), 'primary-menu' => __( 'Primary Menu', 'pressbooks-aldine' ),
'network-footer-menu' => __( 'Footer Menu', 'pressbooks-aldine' ), 'network-footer-menu' => __( 'Footer Menu', 'pressbooks-aldine' ),
] ); ]
);
/* /*
* Switch default core markup for search form, comment form, and comments * Switch default core markup for search form, comment form, and comments
* to output valid HTML5. * to output valid HTML5.
*/ */
add_theme_support( 'html5', [ add_theme_support(
'html5', [
'search-form', 'search-form',
'comment-form', 'comment-form',
'comment-list', 'comment-list',
'gallery', 'gallery',
'caption', 'caption',
] ); ]
);
// Set up the WordPress core custom header feature. // 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', 'default-image' => get_template_directory_uri() . '/dist/images/header.jpg',
'width' => 1920, 'width' => 1920,
'height' => 884, 'height' => 884,
'default-text-color' => '#000', 'default-text-color' => '#000',
] ); ]
);
// Add theme support for selective refresh for widgets. // Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' ); add_theme_support( 'customize-selective-refresh-widgets' );
@ -77,12 +81,14 @@ function setup() {
* *
* @link https://codex.wordpress.org/Theme_Logo * @link https://codex.wordpress.org/Theme_Logo
*/ */
add_theme_support( 'custom-logo', [ add_theme_support(
'custom-logo', [
'height' => 40, 'height' => 40,
'width' => 265, 'width' => 265,
'flex-width' => true, 'flex-width' => true,
'flex-height' => true, 'flex-height' => true,
] ); ]
);
// Add editor style. // Add editor style.
add_editor_style( $assets->getPath( 'styles/editor.css' ) ); add_editor_style( $assets->getPath( 'styles/editor.css' ) );
@ -103,7 +109,8 @@ function widgets_init() {
'before_title' => '<h2>', 'before_title' => '<h2>',
'after_title' => '</h2>', 'after_title' => '</h2>',
]; ];
register_sidebar( [ register_sidebar(
[
'name' => __( 'Network Footer Block 1', 'pressbooks-aldine' ), 'name' => __( 'Network Footer Block 1', 'pressbooks-aldine' ),
'description' => __( 'description' => __(
'Add content for your network&rsquo;s customizeable footer here. 'Add content for your network&rsquo;s customizeable footer here.
@ -112,8 +119,10 @@ function widgets_init() {
'aldine' 'aldine'
), ),
'id' => 'network-footer-block-1', 'id' => 'network-footer-block-1',
] + $config ); ] + $config
register_sidebar( [ );
register_sidebar(
[
'name' => __( 'Network Footer Block 2', 'pressbooks-aldine' ), 'name' => __( 'Network Footer Block 2', 'pressbooks-aldine' ),
'description' => __( 'description' => __(
'Add content for your network&rsquo;s customizeable footer here. 'Add content for your network&rsquo;s customizeable footer here.
@ -122,7 +131,8 @@ function widgets_init() {
'aldine' 'aldine'
), ),
'id' => 'network-footer-block-2', 'id' => 'network-footer-block-2',
] + $config ); ] + $config
);
} }
/** /**
@ -216,15 +226,17 @@ function remove_admin_bar_callback() {
* Hide content editor for Catalog page. * Hide content editor for Catalog page.
*/ */
function hide_catalog_content_editor() { function hide_catalog_content_editor() {
$post_id = $_GET['post'] ?? null ; $post_id = $_GET['post'] ?? null;
if ( ! isset( $post_id ) ) { if ( ! isset( $post_id ) ) {
return; return;
} }
$pagename = get_the_title( $post_id ); $pagename = get_the_title( $post_id );
if ( $pagename === 'Catalog' ) { 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' ) ); 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', 'editor' );
remove_post_type_support( 'page', 'thumbnail' ); remove_post_type_support( 'page', 'thumbnail' );
} }
@ -272,7 +284,7 @@ function register_shortcode_buttons() {
* @since 1.1.0 * @since 1.1.0
*/ */
function tinymce_l18n() { function tinymce_l18n() {
?> ?>
<script type='text/javascript'> <script type='text/javascript'>
const aldine = { const aldine = {
page_section: { page_section: {
@ -290,7 +302,7 @@ function tinymce_l18n() {
} }
}; };
</script> </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' ), __( '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' ), __( 'Pressbooks is used by educational institutions around the world as well as authors and publishers.', 'pressbooks' ),
sprintf( sprintf(
/* translators: %s link to about page */
__( 'For more information about Pressbooks, %s.', 'pressbooks-aldine' ), __( 'For more information about Pressbooks, %s.', 'pressbooks-aldine' ),
sprintf( '<a href="https://pressbooks.com/about">%s</a>', __( 'see here', 'pressbooks-aldine' ) ) sprintf( '<a href="https://pressbooks.com/about">%s</a>', __( 'see here', 'pressbooks-aldine' ) )
) )
@ -55,6 +56,7 @@ function create_default_content() {
sprintf( sprintf(
'<p>%1$s</p><p>%2$s</p>', '<p>%1$s</p><p>%2$s</p>',
sprintf( 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' ), __( '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://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' ) ) 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 ) { foreach ( $default_pages as $slug => $page ) {
$check = get_page_by_path( $slug ); $check = get_page_by_path( $slug );
if ( empty( $check ) ) { 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 { } else {
$pages[ $slug ] = $check->ID; $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 ) ) { ?> 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 <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 } ?> /> if ( ! get_blog_option( $blog_id, 'blog_public' ) ) {
<?php }
?>
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'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
if ( isset( $wp_customize->selective_refresh ) ) { if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', [ $wp_customize->selective_refresh->add_partial(
'blogname', [
'selector' => '.site-title a', 'selector' => '.site-title a',
'render_callback' => function() { 'render_callback' => function() {
bloginfo( 'name' ); bloginfo( 'name' );
}, },
] ); ]
$wp_customize->selective_refresh->add_partial( 'blogdescription', [ );
$wp_customize->selective_refresh->add_partial(
'blogdescription', [
'selector' => '.site-description', 'selector' => '.site-description',
'render_callback' => function() { 'render_callback' => function() {
bloginfo( 'description' ); 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', 'selector' => '#latest-books-title',
'render_callback' => function() { 'render_callback' => function() {
get_option( 'pb_front_page_catalog_title' ); 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', 'selector' => '#contact .contact__title',
'render_callback' => function() { 'render_callback' => function() {
get_option( 'pb_network_contact_form_title' ); get_option( 'pb_network_contact_form_title' );
}, },
] ); ]
);
} }
foreach ( [ foreach ( [
@ -92,11 +100,14 @@ function customize_register( \WP_Customize_Manager $wp_customize ) {
'description' => __( 'Used for text on an accent color background.', 'pressbooks-aldine' ), 'description' => __( 'Used for text on an accent color background.', 'pressbooks-aldine' ),
], ],
] as $color ) { ] as $color ) {
$wp_customize->add_setting("pb_network_color_{$color['slug']}", [ $wp_customize->add_setting(
"pb_network_color_{$color['slug']}", [
'type' => 'option', 'type' => 'option',
'default' => $color['hex'], 'default' => $color['hex'],
]); ]
$wp_customize->add_control(new \WP_Customize_Color_Control( );
$wp_customize->add_control(
new \WP_Customize_Color_Control(
$wp_customize, $wp_customize,
"pb_network_color_{$color['slug']}", "pb_network_color_{$color['slug']}",
[ [
@ -105,90 +116,125 @@ function customize_register( \WP_Customize_Manager $wp_customize ) {
'description' => $color['description'], 'description' => $color['description'],
'settings' => "pb_network_color_{$color['slug']}", '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' ), 'title' => __( 'Social Media', 'pressbooks-aldine' ),
'priority' => 30, 'priority' => 30,
]); ]
$wp_customize->add_setting('pb_network_facebook', [ );
$wp_customize->add_setting(
'pb_network_facebook', [
'type' => 'option', 'type' => 'option',
'sanitize_callback' => 'esc_url_raw', 'sanitize_callback' => 'esc_url_raw',
]); ]
$wp_customize->add_control('pb_network_facebook', [ );
$wp_customize->add_control(
'pb_network_facebook', [
'label' => __( 'Facebook', 'pressbooks-aldine' ), 'label' => __( 'Facebook', 'pressbooks-aldine' ),
'section' => 'pb_network_social', 'section' => 'pb_network_social',
'settings' => 'pb_network_facebook', 'settings' => 'pb_network_facebook',
]); ]
$wp_customize->add_setting('pb_network_twitter', [ );
$wp_customize->add_setting(
'pb_network_twitter', [
'type' => 'option', 'type' => 'option',
'sanitize_callback' => 'esc_url_raw', 'sanitize_callback' => 'esc_url_raw',
]); ]
$wp_customize->add_control('pb_network_twitter', [ );
$wp_customize->add_control(
'pb_network_twitter', [
'label' => __( 'Twitter', 'pressbooks-aldine' ), 'label' => __( 'Twitter', 'pressbooks-aldine' ),
'section' => 'pb_network_social', 'section' => 'pb_network_social',
'settings' => 'pb_network_twitter', 'settings' => 'pb_network_twitter',
]); ]
);
if ( defined( 'PB_PLUGIN_VERSION' ) ) { 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' ), 'title' => __( 'Front Page Catalog', 'pressbooks-aldine' ),
'priority' => 25, 'priority' => 25,
]); ]
$wp_customize->add_setting('pb_front_page_catalog', [ );
$wp_customize->add_setting(
'pb_front_page_catalog', [
'type' => 'option', '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' ), 'label' => __( 'Show Front Page Catalog', 'pressbooks-aldine' ),
'section' => 'pb_front_page_catalog', 'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog', 'settings' => 'pb_front_page_catalog',
'type' => 'checkbox', 'type' => 'checkbox',
]); ]
$wp_customize->add_setting('pb_front_page_catalog_title', [ );
$wp_customize->add_setting(
'pb_front_page_catalog_title', [
'type' => 'option', 'type' => 'option',
'sanitize_callback' => 'sanitize_text_field', 'sanitize_callback' => 'sanitize_text_field',
'default' => __( 'Our Latest Titles', 'pressbooks-aldine' ), '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' ), 'label' => __( 'Front Page Catalog Title', 'pressbooks-aldine' ),
'section' => 'pb_front_page_catalog', 'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog_title', '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' ), 'title' => __( 'Contact Form', 'pressbooks-aldine' ),
'priority' => 25, 'priority' => 25,
]); ]
$wp_customize->add_setting('pb_network_contact_form', [ );
$wp_customize->add_setting(
'pb_network_contact_form', [
'type' => 'option', 'type' => 'option',
]); ]
$wp_customize->add_control('pb_network_contact_form', [ );
$wp_customize->add_control(
'pb_network_contact_form', [
'label' => __( 'Show Contact Form', 'pressbooks-aldine' ), 'label' => __( 'Show Contact Form', 'pressbooks-aldine' ),
'section' => 'pb_network_contact_form', 'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form', 'settings' => 'pb_network_contact_form',
'type' => 'checkbox', 'type' => 'checkbox',
]); ]
$wp_customize->add_setting('pb_network_contact_form_title', [ );
$wp_customize->add_setting(
'pb_network_contact_form_title', [
'type' => 'option', 'type' => 'option',
'sanitize_callback' => 'sanitize_text_field', 'sanitize_callback' => 'sanitize_text_field',
'default' => __( 'Contact Us', 'pressbooks-aldine' ), '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' ), 'label' => __( 'Contact Form Title', 'pressbooks-aldine' ),
'section' => 'pb_network_contact_form', 'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_form_title', 'settings' => 'pb_network_contact_form_title',
]); ]
$wp_customize->add_setting('pb_network_contact_email', [ );
$wp_customize->add_setting(
'pb_network_contact_email', [
'type' => 'option', 'type' => 'option',
'default' => get_option( 'admin_email', '' ), 'default' => get_option( 'admin_email', '' ),
'sanitize_callback' => 'sanitize_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' ), 'label' => __( 'Contact Email', 'pressbooks-aldine' ),
'section' => 'pb_network_contact_form', 'section' => 'pb_network_contact_form',
'settings' => 'pb_network_contact_email', 'settings' => 'pb_network_contact_email',
]); ]
);
} }
/** /**

8
inc/filters/namespace.php

@ -7,8 +7,8 @@
namespace Aldine\Filters; namespace Aldine\Filters;
use PressbooksMix\Assets;
use function Aldine\Helpers\has_sections; use function Aldine\Helpers\has_sections;
use PressbooksMix\Assets;
/** /**
* Adds custom classes to the array of body classes. * 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 */ /** 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 ); return preg_replace( [ '/-php$/', '/^page-template-views/' ], '', $class );
}, $classes ); }, $classes
);
return array_filter( $classes ); return array_filter( $classes );
} }

19
inc/helpers/namespace.php

@ -7,8 +7,8 @@
namespace Aldine\Helpers; namespace Aldine\Helpers;
use Pressbooks\Book;
use function \Pressbooks\Metadata\book_information_to_schema; use function \Pressbooks\Metadata\book_information_to_schema;
use Pressbooks\Book;
/** /**
* @param int $page * @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 = '' ) { function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $license = '', $subject = '' ) {
if ( ! defined( 'PB_PLUGIN_VERSION' ) ) { 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 ) get_default_menu( $items )
); );
if ( class_exists( '\PressbooksOAuth\OAuth' ) ) { if ( class_exists( '\PressbooksOAuth\OAuth' ) ) {
add_filter( 'pb_oauth_output_button', function( $bool ) { add_filter(
'pb_oauth_output_button', function( $bool ) {
return false; return false;
} ); }
);
do_action( 'pressbooks_oauth_connect' ); do_action( 'pressbooks_oauth_connect' );
} }
} }
@ -279,6 +287,7 @@ function handle_contact_form_submission() {
} else { } else {
$sent = wp_mail( $sent = wp_mail(
$contact_email, $contact_email,
/* translators: %s name of contact for submitter */
sprintf( __( 'Contact Form Submission from %s', 'pressbooks-aldine' ), $name ), sprintf( __( 'Contact Form Submission from %s', 'pressbooks-aldine' ), $name ),
sprintf( sprintf(
"From: %1\$s <%2\$s>\nInstitution: %3\$s\n\n%4\$s", "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-emoji' );
intervention( 'remove-howdy', __( 'Hello,', 'pressbooks-aldine' ) ); intervention( 'remove-howdy', __( 'Hello,', 'pressbooks-aldine' ) );
intervention( 'remove-dashboard-items', [ 'activity', 'quick-draft' ] ); intervention( 'remove-dashboard-items', [ 'activity', 'quick-draft' ] );
intervention( 'remove-menu-items', [ intervention(
'remove-menu-items', [
'posts', 'posts',
'tool-import', 'tool-import',
'tool-export', 'tool-export',
'setting-writing', 'setting-writing',
'setting-reading', 'setting-reading',
'setting-permalink', 'setting-permalink',
], 'all' ); ], 'all'
intervention( 'remove-widgets', [ );
intervention(
'remove-widgets', [
'pages', 'pages',
'calendar', 'calendar',
'archives', 'archives',
@ -36,5 +39,6 @@ intervention( 'remove-widgets', [
'custom-html', 'custom-html',
'media-video', 'media-video',
'akismet', 'akismet',
], 'all' ); ], 'all'
);
intervention( 'remove-toolbar-frontend', 'all' ); intervention( 'remove-toolbar-frontend', 'all' );

9
index.php

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

10
page-catalog.php

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

9
page.php

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

19
partials/book.php

@ -1,23 +1,32 @@
<?php use function \Aldine\Helpers\maybe_truncate_string; ?> <?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'] ) : ''; $date = ( isset( $book['metadata']['datePublished'] ) ) ? str_replace( '-', '', $book['metadata']['datePublished'] ) : '';
?> ?>
<li class="book" <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'] ); ?>" 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"> <p class="book__title">
<a href="<?php echo $book['link']; ?>"><?php echo maybe_truncate_string( $book['metadata']['name'] ); ?></a> <a href="<?php echo $book['link']; ?>"><?php echo maybe_truncate_string( $book['metadata']['name'] ); ?></a>
</p> </p>
<?php /* <?php if (isset( $book['metadata']['author'] ) ) { ?> <?php
/* <?php if (isset( $book['metadata']['author'] ) ) { ?>
<p class="book__author"> <p class="book__author">
<?php _e( 'By', 'pressbooks-aldine' ); ?> <?php foreach ( $book['metadata']['author'] as $author ) { <?php _e( 'By', 'pressbooks-aldine' ); ?> <?php foreach ( $book['metadata']['author'] as $author ) {
echo $author['name']; echo $author['name'];
} ?> } ?>
</p> </p>
<?php } ?> */ ?> <?php } ?> */
?>
<?php if ( ! empty( $subject ) ) { ?> <?php if ( ! empty( $subject ) ) { ?>
<p class="book__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> <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' ); ?> <?php wp_nonce_field( 'pb_root_contact_form', 'pb_root_contact_form_nonce' ); ?>
<input type="hidden" name="submitted" value="1"> <input type="hidden" name="submitted" value="1">
<p class="form__row"> <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']; echo $contact_form_response['values']['visitor_name'];
endif; ?>" required> endif;
?>
" required>
<label for="contact-name"> <label for="contact-name">
<?php _e( 'Your name (required)', 'pressbooks-aldine' ); ?> <?php _e( 'Your name (required)', 'pressbooks-aldine' ); ?>
</label> </label>
</p> </p>
<p class="form__row"> <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']; echo $contact_form_response['values']['visitor_email'];
endif; ?>" required> endif;
?>
" required>
<label for="contact-email"> <label for="contact-email">
<?php _e( 'Your email address (required)', 'pressbooks-aldine' ); ?> <?php _e( 'Your email address (required)', 'pressbooks-aldine' ); ?>
</label> </label>
</p> </p>
<p class="form__row"> <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']; echo $contact_form_response['values']['visitor_institution'];
endif; ?>" required> endif;
?>
" required>
<label for="contact-institution"> <label for="contact-institution">
<?php _e( 'Your institution (required)', 'pressbooks-aldine' ); ?> <?php _e( 'Your institution (required)', 'pressbooks-aldine' ); ?>
</label> </label>
</p> </p>
<p class="form__row"> <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']; echo $contact_form_response['values']['message'];
endif; ?></textarea> endif;
?>
</textarea>
<label for="contact-message"> <label for="contact-message">
<?php _e( 'Your message (required)', 'pressbooks-aldine' ); ?> <?php _e( 'Your message (required)', 'pressbooks-aldine' ); ?>
</label> </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'] ) ) : ?> <?php if ( get_option( 'pb_front_page_catalog' ) && ! empty( $catalog_data['books'] ) ) : ?>
<div id="latest-books" class="latest-books"> <div id="latest-books" class="latest-books">
<h2 id="latest-books-title"><?php echo $latest_books_title; ?></h2> <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"> <ul class="books">
<?php foreach ( $catalog_data['books'] as $book ) : <?php
foreach ( $catalog_data['books'] as $book ) :
include( locate_template( 'partials/book.php' ) ); include( locate_template( 'partials/book.php' ) );
endforeach; ?> endforeach;
?>
</ul> </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> </div>
<p class="catalog-link"> <p class="catalog-link">
<a class="call-to-action" href="<?php echo network_home_url( '/catalog/' ); ?>"><?php _e( 'View Complete Catalog', 'pressbooks-aldine' ); ?></a> <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"> <div class="page-content">
<?php <?php
if ( is_home() && current_user_can( 'publish_posts' ) ) : ?> if ( is_home() && current_user_can( 'publish_posts' ) ) :
?>
<p><?php <p>
<?php
printf( printf(
wp_kses( wp_kses(
/* translators: 1: link to WP admin new post page. */ /* translators: 1: link to WP admin new post page. */
@ -31,7 +33,8 @@
), ),
esc_url( admin_url( 'post-new.php' ) ) esc_url( admin_url( 'post-new.php' ) )
); );
?></p> ?>
</p>
<?php elseif ( is_search() ) : ?> <?php elseif ( is_search() ) : ?>
@ -39,12 +42,14 @@
<?php <?php
get_search_form(); 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> <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 <?php
get_search_form(); get_search_form();
endif; ?> endif;
?>
</div><!-- .page-content --> </div><!-- .page-content -->
</section><!-- .no-results --> </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, '' ); ?>> <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> <label for="all-subjects"><?php _e( 'All Subjects', 'pressbooks-aldine' ); ?> <svg class="checked"><use xlink:href="#checkmark" /></svg></label>
<div class="subject-groups"> <div class="subject-groups">
<?php foreach ( $subjects as $key => $val ) : <?php
if ( array_key_exists( $key, $available_subjects ) ) : ?> foreach ( $subjects as $key => $val ) :
if ( array_key_exists( $key, $available_subjects ) ) :
?>
<h3><span class="label"><?php echo $val['label']; ?></span></h3> <h3><span class="label"><?php echo $val['label']; ?></span></h3>
<?php foreach ( $val['children'] as $k => $v ) : <?php
if ( in_array( $k, $available_subjects[ $key ], true ) ) : ?> 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 ); ?>> <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> <label for="<?php echo $k; ?>"><span class="label"><?php echo $v; ?></span> <svg class="checked"><use xlink:href="#checkmark" /></svg></label>
<?php endif; ?> <?php endif; ?>
@ -35,12 +39,16 @@
<h2><?php _e( 'Filter by License', 'pressbooks-aldine' ); ?></h2> <h2><?php _e( 'Filter by License', 'pressbooks-aldine' ); ?></h2>
<input type="radio" name="license" id="all-licenses" value="" <?php checked( $license, '' ); ?>> <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> <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 ) : <?php
if ( in_array( $key, $available_licenses, true ) ) : ?> 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 ); ?>> <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> <label for="<?php echo $key; ?>"><?php echo $value; ?> <svg class="checked"><use xlink:href="#checkmark" /></svg></label>
<?php endif; <?php
endforeach; ?> endif;
endforeach;
?>
</fieldset> </fieldset>
<fieldset class="sorts"> <fieldset class="sorts">
<h2><?php _e( 'Sort by', 'pressbooks-aldine' ); ?></h2> <h2><?php _e( 'Sort by', 'pressbooks-aldine' ); ?></h2>
@ -50,7 +58,8 @@
'subject' => __( 'Subject', 'pressbooks-aldine' ), 'subject' => __( 'Subject', 'pressbooks-aldine' ),
'latest' => __( 'Latest', '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 ); ?>> <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> <label for="<?php echo $key ?>"><?php echo $value; ?> <svg class="checked"><use xlink:href="#checkmark" /></svg></label>
<?php } ?> <?php } ?>
@ -59,26 +68,36 @@
<button type="submit"><?php _e( 'Submit', 'pressbooks-aldine' ); ?></button> <button type="submit"><?php _e( 'Submit', 'pressbooks-aldine' ); ?></button>
</form> </form>
<ul class="books"> <ul class="books">
<?php foreach ( $catalog_data['books'] as $book ) : <?php
foreach ( $catalog_data['books'] as $book ) :
include( locate_template( 'partials/book.php' ) ); include( locate_template( 'partials/book.php' ) );
endforeach; ?> endforeach;
?>
</ul> </ul>
<?php if ( $catalog_data['pages'] > 1 ) : ?> <?php if ( $catalog_data['pages'] > 1 ) : ?>
<nav class="catalog-navigation"> <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"> <svg aria-hidden="true">
<use xlink:href="#arrow-left" /> <use xlink:href="#arrow-left" />
</svg></a><?php endif; ?> </svg></a><?php endif; ?>
<div class="pages"> <div class="pages">
<?php for ( $i = 1; $i <= $catalog_data['pages']; $i++ ) : <?php
if ( $i === $current_page ) : ?> for ( $i = 1; $i <= $catalog_data['pages']; $i++ ) :
if ( $i === $current_page ) :
?>
<span class="current"><?php echo $i; ?></span> <span class="current"><?php echo $i; ?></span>
<?php else : ?> <?php else : ?>
<a href="<?php echo network_home_url( "/catalog/page/$i/" ); ?>"><?php echo $i; ?></a> <a href="<?php echo network_home_url( "/catalog/page/$i/" ); ?>"><?php echo $i; ?></a>
<?php endif; ?> <?php endif; ?>
<?php endfor; ?> <?php endfor; ?>
</div> </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"> <svg aria-hidden="true">
<use xlink:href="#arrow-right" /> <use xlink:href="#arrow-right" />
</svg></a><?php endif; ?> </svg></a><?php endif; ?>

6
partials/content-page.php

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

40
phpcs.ruleset.xml

@ -1,41 +1,13 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<ruleset> <ruleset>
<!-- Scan only PHP files --> <!-- Use Pressbooks Coding Standards -->
<arg name="extensions" value="php"/> <rule ref="vendor/pressbooks/coding-standards" />
<!-- Show colors in console --> <!-- Disable Side Effects and MissingNamespace rules for bootstrapping files: -->
<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 -->
<rule ref="PSR1.Files.SideEffects"> <rule ref="PSR1.Files.SideEffects">
<exclude-pattern>functions.php</exclude-pattern> <exclude-pattern>/functions.php</exclude-pattern>
</rule> </rule>
<rule ref="HM.Functions.NamespacedFunctions.MissingNamespace">
<!-- Disable Namespaced Functions for functions.php --> <exclude-pattern>/functions.php</exclude-pattern>
<rule ref="HM.Functions.NamespacedFunctions">
<exclude-pattern>functions.php</exclude-pattern>
</rule> </rule>
</ruleset> </ruleset>

15
search.php

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

3
single.php

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

Loading…
Cancel
Save