Browse Source

Standards fixes

pull/284/head
SteelWagstaff 4 years ago
parent
commit
90d5d2fa8e
  1. 2
      comments.php
  2. 7
      composer.json
  3. 358
      composer.lock
  4. 3
      footer.php
  5. 4
      functions.php
  6. 6
      inc/actions/namespace.php
  7. 13
      inc/activation/namespace.php
  8. 54
      inc/admin/namespace.php
  9. 6
      inc/customizer/namespace.php
  10. 7
      inc/filters/namespace.php
  11. 36
      inc/helpers/namespace.php
  12. 8
      inc/shortcodes/namespace.php
  13. 12
      partials/book.php
  14. 11
      partials/contact-form.php
  15. 12
      partials/content-single.php
  16. 12
      partials/page-block.php
  17. 12
      partials/page-header.php
  18. 10
      partials/paged-navigation.php
  19. 6
      phpcs.ruleset.xml
  20. 8
      searchform.php

2
comments.php

@ -36,7 +36,7 @@ if ( post_password_required() ) {
'<span>' . get_the_title() . '</span>'
);
} else {
printf( // WPCS: XSS OK.
printf(
/* translators: 1: comment count number, 2: title. */
esc_html( _nx( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', $comment_count, 'comments title', 'pressbooks-aldine' ) ),
number_format_i18n( $comment_count ),

7
composer.json

@ -31,8 +31,8 @@
},
"require-dev": {
"phpunit/phpunit": "^7",
"pressbooks/coding-standards": "^1.0",
"wpreadme2markdown/wp2md": "^3.0"
"wpreadme2markdown/wp2md": "^3.0",
"pressbooks/coding-standards": "^1.1"
},
"scripts": {
"test": [
@ -42,6 +42,9 @@
"standards": [
"vendor/bin/phpcs --standard=phpcs.ruleset.xml inc partials *.php"
],
"fix": [
"vendor/bin/phpcbf --standard=phpcs.ruleset.xml inc partials *.php"
],
"localize": [
"wp-pot -o=languages/pressbooks-aldine.pot -d=pressbooks-aldine -t 'Pressbooks (Book Oven Inc.) <code@pressbooks.com>' -s '**/*.php'"
],

358
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "059d238d3535c84ce365607bf4a4b989",
"content-hash": "98bac08003d38c68eb547ca4276f6d2b",
"packages": [
{
"name": "composer/installers",
@ -283,6 +283,118 @@
}
],
"packages-dev": [
{
"name": "automattic/vipwpcs",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/Automattic/VIP-Coding-Standards.git",
"reference": "fc02f491dc9f51da7c32941ac579f70b9ed300c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/fc02f491dc9f51da7c32941ac579f70b9ed300c5",
"reference": "fc02f491dc9f51da7c32941ac579f70b9ed300c5",
"shasum": ""
},
"require": {
"php": ">=5.6",
"squizlabs/php_codesniffer": "^3.3.1",
"wp-coding-standards/wpcs": "^2.1"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5",
"phpcompatibility/php-compatibility": "^9",
"phpunit/phpunit": "^5 || ^6 || ^7"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Contributors",
"homepage": "https://github.com/Automattic/VIP-Coding-Standards/graphs/contributors"
}
],
"description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions",
"keywords": [
"phpcs",
"standards",
"wordpress"
],
"time": "2019-07-12T08:47:36+00:00"
},
{
"name": "dealerdirect/phpcodesniffer-composer-installer",
"version": "v0.7.1",
"source": {
"type": "git",
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
"reference": "fe390591e0241955f22eb9ba327d137e501c771c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c",
"reference": "fe390591e0241955f22eb9ba327d137e501c771c",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0 || ^2.0",
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0"
},
"require-dev": {
"composer/composer": "*",
"phpcompatibility/php-compatibility": "^9.0",
"sensiolabs/security-checker": "^4.1.0"
},
"type": "composer-plugin",
"extra": {
"class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
},
"autoload": {
"psr-4": {
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Franck Nijhof",
"email": "franck.nijhof@dealerdirect.com",
"homepage": "http://www.frenck.nl",
"role": "Developer / IT Manager"
}
],
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
"homepage": "http://www.dealerdirect.com",
"keywords": [
"PHPCodeSniffer",
"PHP_CodeSniffer",
"code quality",
"codesniffer",
"composer",
"installer",
"phpcs",
"plugin",
"qa",
"quality",
"standard",
"standards",
"style guide",
"stylecheck",
"tests"
],
"time": "2020-12-07T18:04:37+00:00"
},
{
"name": "doctrine/instantiator",
"version": "1.4.0",
@ -350,16 +462,16 @@
},
{
"name": "fig-r/psr2r-sniffer",
"version": "0.5.0",
"version": "0.5.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig-rectified/psr2r-sniffer.git",
"reference": "ff4659fdb1ce8832a9e408a6e22aa05bc93efe10"
"reference": "7eb462bcf19abcae122855a6d79cc8f768c77880"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig-rectified/psr2r-sniffer/zipball/ff4659fdb1ce8832a9e408a6e22aa05bc93efe10",
"reference": "ff4659fdb1ce8832a9e408a6e22aa05bc93efe10",
"url": "https://api.github.com/repos/php-fig-rectified/psr2r-sniffer/zipball/7eb462bcf19abcae122855a6d79cc8f768c77880",
"reference": "7eb462bcf19abcae122855a6d79cc8f768c77880",
"shasum": ""
},
"require": {
@ -392,37 +504,41 @@
"codesniffer",
"cs"
],
"time": "2017-08-30T10:00:39+00:00"
"time": "2019-07-30T11:13:07+00:00"
},
{
"name": "humanmade/coding-standards",
"version": "v0.5.0",
"version": "v1.1.3",
"source": {
"type": "git",
"url": "https://github.com/humanmade/coding-standards.git",
"reference": "b35747249bcc727a9eff22f746aaf9758d8a90ce"
"reference": "6efe4b8fd33c22f06febc658c805acdc1e4d94f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/humanmade/coding-standards/zipball/b35747249bcc727a9eff22f746aaf9758d8a90ce",
"reference": "b35747249bcc727a9eff22f746aaf9758d8a90ce",
"url": "https://api.github.com/repos/humanmade/coding-standards/zipball/6efe4b8fd33c22f06febc658c805acdc1e4d94f5",
"reference": "6efe4b8fd33c22f06febc658c805acdc1e4d94f5",
"shasum": ""
},
"require": {
"automattic/vipwpcs": "2.0.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"fig-r/psr2r-sniffer": "^0.5.0",
"squizlabs/php_codesniffer": "^3.1",
"wp-coding-standards/wpcs": "^0.14.0"
"php": ">=7.1",
"phpcompatibility/phpcompatibility-wp": "^2.0.0",
"squizlabs/php_codesniffer": "~3.5.0",
"wp-coding-standards/wpcs": "2.2.1"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
},
"type": "project",
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0-or-later"
],
"description": "Human Made coding standards",
"time": "2018-05-22T13:24:47+00:00"
"description": "Human Made Coding Standards",
"time": "2021-02-03T22:20:56+00:00"
},
{
"name": "myclabs/deep-copy",
@ -580,6 +696,166 @@
"description": "Library for handling version information and constraints",
"time": "2018-07-08T19:19:57+00:00"
},
{
"name": "phpcompatibility/php-compatibility",
"version": "9.3.5",
"source": {
"type": "git",
"url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243",
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243",
"shasum": ""
},
"require": {
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
},
"conflict": {
"squizlabs/php_codesniffer": "2.6.2"
},
"require-dev": {
"phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "Wim Godden",
"homepage": "https://github.com/wimg",
"role": "lead"
},
{
"name": "Juliette Reinders Folmer",
"homepage": "https://github.com/jrfnl",
"role": "lead"
},
{
"name": "Contributors",
"homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
}
],
"description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
"homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
"keywords": [
"compatibility",
"phpcs",
"standards"
],
"time": "2019-12-27T09:44:58+00:00"
},
{
"name": "phpcompatibility/phpcompatibility-paragonie",
"version": "1.3.1",
"source": {
"type": "git",
"url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git",
"reference": "ddabec839cc003651f2ce695c938686d1086cf43"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/ddabec839cc003651f2ce695c938686d1086cf43",
"reference": "ddabec839cc003651f2ce695c938686d1086cf43",
"shasum": ""
},
"require": {
"phpcompatibility/php-compatibility": "^9.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"paragonie/random_compat": "dev-master",
"paragonie/sodium_compat": "dev-master"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "Wim Godden",
"role": "lead"
},
{
"name": "Juliette Reinders Folmer",
"role": "lead"
}
],
"description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.",
"homepage": "http://phpcompatibility.com/",
"keywords": [
"compatibility",
"paragonie",
"phpcs",
"polyfill",
"standards"
],
"time": "2021-02-15T10:24:51+00:00"
},
{
"name": "phpcompatibility/phpcompatibility-wp",
"version": "2.1.2",
"source": {
"type": "git",
"url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git",
"reference": "a792ab623069f0ce971b2417edef8d9632e32f75"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/a792ab623069f0ce971b2417edef8d9632e32f75",
"reference": "a792ab623069f0ce971b2417edef8d9632e32f75",
"shasum": ""
},
"require": {
"phpcompatibility/php-compatibility": "^9.0",
"phpcompatibility/phpcompatibility-paragonie": "^1.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "Wim Godden",
"role": "lead"
},
{
"name": "Juliette Reinders Folmer",
"role": "lead"
}
],
"description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.",
"homepage": "http://phpcompatibility.com/",
"keywords": [
"compatibility",
"phpcs",
"standards",
"wordpress"
],
"time": "2021-07-21T11:09:57+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
@ -1146,32 +1422,31 @@
},
{
"name": "pressbooks/coding-standards",
"version": "1.0.0",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/pressbooks/coding-standards.git",
"reference": "2c41415fd7eb121d871364bf1e460f724024758c"
"reference": "e332af77b246b088c5320934296746c1033a98cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pressbooks/coding-standards/zipball/2c41415fd7eb121d871364bf1e460f724024758c",
"reference": "2c41415fd7eb121d871364bf1e460f724024758c",
"url": "https://api.github.com/repos/pressbooks/coding-standards/zipball/e332af77b246b088c5320934296746c1033a98cb",
"reference": "e332af77b246b088c5320934296746c1033a98cb",
"shasum": ""
},
"require": {
"fig-r/psr2r-sniffer": "0.5.0",
"humanmade/coding-standards": "0.5.0",
"squizlabs/php_codesniffer": "3.3.2"
"humanmade/coding-standards": "^1.0",
"squizlabs/php_codesniffer": "^3.5"
},
"require-dev": {
"phpunit/phpunit": "6.5.13"
"phpunit/phpunit": "^7.0"
},
"type": "project",
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0-or-later"
],
"time": "2018-12-14T16:09:42+00:00"
"time": "2021-08-09T16:26:32+00:00"
},
{
"name": "psr/container",
@ -1839,16 +2114,16 @@
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.3.2",
"version": "3.5.8",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e"
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e",
"reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4",
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4",
"shasum": ""
},
"require": {
@ -1881,12 +2156,12 @@
}
],
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
"homepage": "http://www.squizlabs.com/php-codesniffer",
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
"keywords": [
"phpcs",
"standards"
],
"time": "2018-09-23T23:08:17+00:00"
"time": "2020-10-23T02:01:07+00:00"
},
{
"name": "symfony/console",
@ -2773,24 +3048,29 @@
},
{
"name": "wp-coding-standards/wpcs",
"version": "0.14.1",
"version": "2.2.1",
"source": {
"type": "git",
"url": "https://github.com/WordPress/WordPress-Coding-Standards.git",
"reference": "cf6b310caad735816caef7573295f8a534374706"
"reference": "b5a453203114cc2284b1a614c4953456fbe4f546"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/cf6b310caad735816caef7573295f8a534374706",
"reference": "cf6b310caad735816caef7573295f8a534374706",
"url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/b5a453203114cc2284b1a614c4953456fbe4f546",
"reference": "b5a453203114cc2284b1a614c4953456fbe4f546",
"shasum": ""
},
"require": {
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2"
"php": ">=5.4",
"squizlabs/php_codesniffer": "^3.3.1"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6",
"phpcompatibility/php-compatibility": "^9.0",
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
"dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
@ -2800,7 +3080,7 @@
"authors": [
{
"name": "Contributors",
"homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors"
"homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors"
}
],
"description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
@ -2809,7 +3089,7 @@
"standards",
"wordpress"
],
"time": "2018-02-16T01:57:48+00:00"
"time": "2020-02-04T02:52:06+00:00"
},
{
"name": "wpreadme2markdown/wp2md",

3
footer.php

@ -8,6 +8,7 @@
*
* @package Aldine
*/
?>
<?php
@ -94,7 +95,7 @@ if ( $pb_network_contact_form ) {
</div>
<section class="footer__pressbooks">
<a class="footer__pressbooks__icon" href="https://pressbooks.com" title="Pressbooks">
<?php // TODO ?>
<?php // TODO. ?>
<svg class="icon--svg">
<use xlink:href="#icon-pressbooks" />
</svg>

4
functions.php

@ -68,11 +68,11 @@ add_action( 'customize_controls_enqueue_scripts', '\Aldine\Customizer\enqueue_co
add_action( 'customize_controls_enqueue_scripts', '\Aldine\Customizer\enqueue_contact_form_tweaks' );
add_action( 'customize_controls_enqueue_scripts', '\Aldine\Customizer\enqueue_pb_a11y_in_customizer' );
// Shortcodes
// Shortcodes.
add_shortcode( 'aldine_page_section', '\Aldine\Shortcodes\page_section' );
add_shortcode( 'aldine_call_to_action', '\Aldine\Shortcodes\call_to_action' );
// Catalog page: Network admin controls
// Catalog page: Network admin controls.
add_action( 'admin_enqueue_scripts', '\Aldine\Admin\admin_scripts' );
add_action( 'wp_ajax_pressbooks_aldine_update_catalog', '\Aldine\Admin\update_catalog' );
add_filter( 'wpmu_blogs_columns', '\Aldine\Admin\catalog_columns' );

6
inc/actions/namespace.php

@ -1,6 +1,7 @@
<?php
/**
* Aldine Actions
*
* @package Aldine
*/
@ -244,6 +245,9 @@ function hide_catalog_content_editor() {
/**
* Add dark and alpha variants for customizer colors on update.
*
* @param array $option Option
* @param string $old_value Unused parameter
* @param string $value Color value
* @since 1.0.0
*/
function add_color_variants( $option, $old_value, $value ) {

13
inc/activation/namespace.php

@ -1,6 +1,7 @@
<?php
/**
* Activate Aldine Theme
*
* @package Aldine
*/
@ -75,7 +76,7 @@ function create_default_content() {
],
];
// Add our pages
// Add our pages.
$pages = [];
foreach ( $default_pages as $slug => $page ) {
@ -94,21 +95,21 @@ function create_default_content() {
}
}
// Set front page to Home
// Set front page to Home.
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $pages['home'] );
// Remove content generated by wp_install_defaults
// Remove content generated by wp_install_defaults.
wp_delete_post( 1, true );
wp_delete_post( 2, true );
wp_delete_comment( 1, true );
// Migrate site logo
// Migrate site logo.
if ( ! empty( $mods['custom_logo'] ) ) {
set_theme_mod( 'custom_logo', $mods['custom_logo'] );
}
// Add "pb_aldine_activated" option to enable check above
// Add "pb_aldine_activated" option to enable check above.
add_option( 'pb_aldine_activated', 1 );
}
}

54
inc/admin/namespace.php

@ -1,5 +1,7 @@
<?php
/**
* Aldine admin
*
* @package Aldine
*/
@ -16,7 +18,9 @@ use Pressbooks\DataCollector\Book as BookDataCollector;
const BLOG_OPTION = 'pressbooks_publisher_in_catalog';
/**
* @param string $hook
* Load admin scripts
*
* @param string $hook Hook
*/
function admin_scripts( $hook ) {
if ( 'sites.php' !== $hook ) {
@ -38,36 +42,40 @@ function admin_scripts( $hook ) {
}
/**
*
* Update catalog
*/
function update_catalog() {
if ( ! current_user_can( 'manage_network' ) || ! check_ajax_referer( 'pressbooks-aldine-admin' ) ) {
return;
}
$blog_id = absint( $_POST['book_id'] );
$in_catalog = $_POST['in_catalog'];
if ( $in_catalog === 'true' ) {
update_blog_option( $blog_id, \Aldine\Admin\BLOG_OPTION, 1 );
update_site_meta( $blog_id, BookDataCollector::IN_CATALOG, 1 );
} else {
delete_blog_option( $blog_id, \Aldine\Admin\BLOG_OPTION );
update_site_meta( $blog_id, BookDataCollector::IN_CATALOG, 0 );
// Exclude book when network option book directory non-catalog exclude is enabled
$option = get_site_option( 'pressbooks_sharingandprivacy_options', [], true );
if (
isset( $option[ SharingAndPrivacyOptions::NETWORK_DIRECTORY_EXCLUDED ] ) &&
( (bool) $option[ SharingAndPrivacyOptions::NETWORK_DIRECTORY_EXCLUDED ] === true )
) {
BookDirectory::init()->deleteBookFromDirectory( [ $blog_id ] );
if ( isset( $_POST['book_id'] ) ) {
$blog_id = absint( $_POST['book_id'] );
}
if ( isset( $_POST['in_catalog'] ) ) {
$in_catalog = wp_unslash( $_POST['in_catalog'] );
if ( $in_catalog === 'true' ) {
update_blog_option( $blog_id, \Aldine\Admin\BLOG_OPTION, 1 );
update_site_meta( $blog_id, BookDataCollector::IN_CATALOG, 1 );
} else {
delete_blog_option( $blog_id, \Aldine\Admin\BLOG_OPTION );
}
}
update_site_meta( $blog_id, BookDataCollector::IN_CATALOG, 0 );
// Exclude book when network option book directory non-catalog exclude is enabled.
$option = get_site_option( 'pressbooks_sharingandprivacy_options', [], true );
if (
isset( $option[ SharingAndPrivacyOptions::NETWORK_DIRECTORY_EXCLUDED ] ) &&
( (bool) $option[ SharingAndPrivacyOptions::NETWORK_DIRECTORY_EXCLUDED ] === true )
) {
BookDirectory::init()->deleteBookFromDirectory( [ $blog_id ] );
}
update_blog_details( $blog_id, [ 'last_updated' => current_time( 'mysql', true ) ] );
}
/**
* @param array $columns
* Catalog columns
*
* @param array $columns Columns
*
* @return array
*/
@ -77,8 +85,10 @@ function catalog_columns( $columns ) {
}
/**
* @param string $column
* @param int $blog_id
* Catalog column
*
* @param string $column Column
* @param int $blog_id Blog ID
*/
function catalog_column( $column, $blog_id ) {

6
inc/customizer/namespace.php

@ -15,12 +15,12 @@ use PressbooksMix\Assets;
* @param \WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function customize_register( \WP_Customize_Manager $wp_customize ) {
// Remove unsupported WP controls, @see \WP_Customize_Manager::register_controls
// Remove unsupported WP controls, @see \WP_Customize_Manager::register_controls.
$wp_customize->remove_control( 'display_header_text' );
$wp_customize->remove_control( 'header_textcolor' );
// Add Pressbooks controls
// Add Pressbooks controls.
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
@ -272,6 +272,8 @@ function customize_preview_js() {
}
/**
* Load color contrast validation tool
*
* @see https://github.com/soderlind/customizer-validate-wcag-color-contrast
*/
function enqueue_color_contrast_validator() {

7
inc/filters/namespace.php

@ -66,11 +66,10 @@ function excerpt_more() {
/**
* Add things to the menu.
*
* @param string $items
* @param object $args
* @param string $items Items
* @param object $args Args
* @return string
*/
function adjust_menu( $items, $args ) {
if ( $args->theme_location === 'primary-menu' ) {
return \Aldine\Helpers\get_default_menu( $items );
@ -82,6 +81,7 @@ function adjust_menu( $items, $args ) {
/**
* Add TinyMCE Buttons.
*
* @param array $plugin_array Plugin array
* @since 1.1.0
*/
function add_buttons( $plugin_array ) {
@ -96,6 +96,7 @@ function add_buttons( $plugin_array ) {
/**
* Register TinyMCE Buttons.
*
* @param array $buttons TinyMCE Buttons
* @since 1.1.0
*/
function register_buttons( $buttons ) {

36
inc/helpers/namespace.php

@ -13,11 +13,13 @@ use function \Pressbooks\Utility\str_starts_with;
use Pressbooks\DataCollector\Book as BookDataCollector;
/**
* @param int $page
* @param int $per_page
* @param string $orderby
* @param string $license
* @param string $subject
* Get catalog data
*
* @param int $page Catalog page
* @param int $per_page Books per page
* @param string $orderby Sort order
* @param string $license Copyright license
* @param string $subject Subject
*
* @return array
*/
@ -27,7 +29,7 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen
return [
'pages' => 0,
'books' => [],
]; // Bail
];
}
$dc = BookDataCollector::init();
@ -40,6 +42,8 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen
$args = apply_filters(
'pb_aldine_catalog_query_args',
/**
* Deprecation notice
*
* @deprecated 1.0.0
*
* @see Pressbooks Publisher
@ -59,12 +63,16 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen
)
);
/** @var \WP_Site $site */
/**
* WordPress site
*
* @var \WP_Site $site
*/
$sites_in_catalog = [];
$sites = get_sites( $args );
foreach ( $sites as $site ) {
$site->pb_title = $dc->get( $site->blog_id, $dc::TITLE ); // Cool hack! :face_with_rolling_eyes:
$site->pb_title = $dc->get( $site->blog_id, $dc::TITLE );
$sites_in_catalog[] = $site;
}
if ( $orderby === 'latest' ) {
@ -103,7 +111,6 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen
];
}
/**
* Get licenses for catalog display.
*
@ -123,7 +130,7 @@ function get_catalog_licenses() {
/**
* Get licenses currently in use.
*
* @param array $catalog_data
* @param array $catalog_data Catalog data
*
* @return array
*/
@ -144,7 +151,7 @@ function get_available_licenses( $catalog_data ) {
/**
* Get subjects currently in use.
*
* @param array $catalog_data
* @param array $catalog_data Catalog data
*
* @return array
*/
@ -162,7 +169,7 @@ function get_available_subjects( $catalog_data ) {
/**
* Return the default (non-page) menu items.
*
* @param string $items
* @param string $items Items
*
* @return string $items
*/
@ -269,7 +276,8 @@ function get_default_menu( $items = '' ) {
/**
* Echo the default menu.
*
* @param string $items
* @param array $args Array
* @param string $items Items
*/
function default_menu( $args = [], $items = '' ) {
printf(
@ -345,7 +353,7 @@ function handle_contact_form_submission() {
stripslashes( $name ),
$email,
stripslashes( $institution ),
strip_tags( $message )
wp_strip_all_tags( $message )
),
"From: ${email}\r\nReply-To: ${email}\r\n"
);

8
inc/shortcodes/namespace.php

@ -10,8 +10,8 @@ namespace Aldine\Shortcodes;
/**
* Shortcode for Page Section.
*
* @param array $atts
* @param string $content
* @param array $atts Shortcode attributes
* @param string $content Page content
*
* @return string
*/
@ -36,7 +36,7 @@ function page_section( $atts, $content = null ) {
/**
* Shortcode for custom Call to Action.
*
* @param array $atts
* @param array $atts Shortcode attributes
*
* @return string
*/
@ -51,7 +51,7 @@ function call_to_action( $atts ) {
'aldine_call_to_action'
);
// Fallback for shortcodes using the old url attribute
// Fallback for shortcodes using the old url attribute.
if ( $atts['link'] === '#' && $atts['url'] ) {
$atts['link'] = $atts['url'];
}

12
partials/book.php

@ -1,4 +1,10 @@
<?php
/**
* Template for displaying books in network catalog
*
* @package Aldine
*/
use function \Aldine\Helpers\maybe_truncate_string;
use function \Pressbooks\Metadata\is_bisac;
?>
@ -22,13 +28,15 @@ if ( $date ) {
<a href="<?php echo $book['link']; ?>"><?php echo maybe_truncate_string( $book['metadata']['name'] ); ?></a>
</p>
<?php
/* <?php if (isset( $book['metadata']['author'] ) ) { ?>
/*
<?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">

11
partials/contact-form.php

@ -4,6 +4,7 @@
*
* @package Aldine
*/
?>
<?php
@ -11,7 +12,7 @@
$pb_network_contact_form_title = get_option( 'pb_network_contact_form_title' );
$contact_form_title = ( ! empty( $pb_network_contact_form_title ) ) ? $pb_network_contact_form_title : __( 'Contact Us', 'pressbooks-aldine' );
$contact_form_response = \Aldine\Helpers\handle_contact_form_submission();
$honeypot = 'firstname' . rand();
$honeypot = 'firstname' . wp_rand();
?>
@ -30,7 +31,7 @@ $honeypot = 'firstname' . rand();
</label>
</p>
<p class="form__row">
<input id="contact-name"
<input id="contact-name"
<?php
if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_name' ) :
?>
@ -46,7 +47,7 @@ $honeypot = 'firstname' . rand();
</label>
</p>
<p class="form__row">
<input id="contact-email"
<input id="contact-email"
<?php
if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_email' ) :
?>
@ -62,7 +63,7 @@ $honeypot = 'firstname' . rand();
</label>
</p>
<p class="form__row">
<input id="contact-institution"
<input id="contact-institution"
<?php
if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'visitor_institution' ) :
?>
@ -78,7 +79,7 @@ $honeypot = 'firstname' . rand();
</label>
</p>
<p class="form__row">
<textarea id="contact-message"
<textarea id="contact-message"
<?php
if ( isset( $contact_form_response['field'] ) && $contact_form_response['field'] === 'message' ) :
?>

12
partials/content-single.php

@ -1 +1,11 @@
<?php // TODO
<?php
/**
* Single page template
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Aldine
*/
// TODO.

12
partials/page-block.php

@ -1 +1,11 @@
<?php // TODO
<?php
/**
* Page block template
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Aldine
*/
// TODO.

12
partials/page-header.php

@ -1,3 +1,13 @@
<?php
/**
* Page header template
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Aldine
*/
?>
<div class="page-header">
<h1><?php echo get_the_title(); ?></h1>
<h1><?php echo get_the_title(); ?></h1>
</div>

10
partials/paged-navigation.php

@ -1,3 +1,13 @@
<?php
/**
* Book navigation template
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Aldine
*/
?>
<nav class="booknav" aria-labelledby="latest-books-title book-navigation">
<span class="screen-reader-text"><?php _e( 'Navigation', 'pressbooks-aldine' ); ?></span>
<?php if ( $previous_page ) : ?>

6
phpcs.ruleset.xml

@ -1,7 +1,11 @@
<?xml version="1.0"?>
<ruleset>
<!-- Use Pressbooks Coding Standards -->
<rule ref="vendor/pressbooks/coding-standards" />
<rule ref="vendor/pressbooks/coding-standards">
<!-- TODO: Enable this again before merging -->
<exclude name="Pressbooks.Security.EscapeOutput.OutputNotEscaped"/>
<exclude name="Pressbooks.Security.ValidatedSanitizedInput"/>
</rule>
<!-- Disable Side Effects and MissingNamespace rules for bootstrapping files: -->
<rule ref="PSR1.Files.SideEffects">

8
searchform.php

@ -1,3 +1,11 @@
<?php
/**
* The catalog search form
*
* @package Aldine
*/
?>
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label for="s">
<?php _ex( 'Search Catalog', 'label', 'pressbooks-aldine' ); ?>

Loading…
Cancel
Save