From 743e20f35e9772c3324590b5ced7738e7d4d57f7 Mon Sep 17 00:00:00 2001 From: Ned Zimmerman Date: Tue, 24 Jul 2018 10:39:38 -0300 Subject: [PATCH] Use Pressbooks coding standards (#131) --- archive.php | 9 +- comments.php | 21 ++- composer.json | 8 +- composer.lock | 179 +++++++++++--------- footer.php | 28 ++-- functions.php | 12 +- header.php | 36 ++-- inc/actions/namespace.php | 108 ++++++------ inc/activation/namespace.php | 15 +- inc/admin/namespace.php | 8 +- inc/customizer/namespace.php | 270 +++++++++++++++++------------- inc/filters/namespace.php | 10 +- inc/helpers/namespace.php | 21 ++- inc/intervention.php | 56 ++++--- index.php | 11 +- page-catalog.php | 10 +- page.php | 9 +- partials/book.php | 27 ++- partials/contact-form.php | 56 +++++-- partials/content-front-page.php | 17 +- partials/content-none.php | 15 +- partials/content-page-catalog.php | 57 ++++--- partials/content-page.php | 12 +- partials/content.php | 46 ++--- phpcs.ruleset.xml | 40 +---- search.php | 15 +- single.php | 3 +- 27 files changed, 650 insertions(+), 449 deletions(-) diff --git a/archive.php b/archive.php index afc7951..7cdcf4e 100644 --- a/archive.php +++ b/archive.php @@ -13,7 +13,8 @@ get_header(); ?>
+ if ( have_posts() ) : + ?>
diff --git a/comments.php b/comments.php index a988447..76d80c8 100644 --- a/comments.php +++ b/comments.php @@ -24,7 +24,8 @@ if ( post_password_required() ) { + if ( have_comments() ) : + ?>

'ol', - 'short_ping' => true, - ] ); + wp_list_comments( + [ + 'style' => 'ol', + 'short_ping' => true, + ] + ); ?> - + if ( ! comments_open() ) : + ?>

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

%1$s

%2$s

', - __( 'Dependencies Missing', 'pressbooks-aldine' ), - __( 'You must run composer install from the Aldine directory.', 'pressbooks-aldine' ) - ) ); + wp_die( + sprintf( + '

%1$s

%2$s

', + __( 'Dependencies Missing', 'pressbooks-aldine' ), + __( 'You must run composer install from the Aldine directory.', 'pressbooks-aldine' ) + ) + ); } require_once $composer; } diff --git a/header.php b/header.php index a60e3d3..d6b980f 100644 --- a/header.php +++ b/header.php @@ -42,7 +42,8 @@
- diff --git a/inc/actions/namespace.php b/inc/actions/namespace.php index bab4247..531335e 100644 --- a/inc/actions/namespace.php +++ b/inc/actions/namespace.php @@ -6,10 +6,8 @@ namespace Aldine\Actions; -use Spatie\Color\Hex; -use Spatie\Color\Rgb; -use Spatie\Color\Rgba; use PressbooksMix\Assets; +use Spatie\Color\Hex; /** * Sets up theme defaults and registers support for various WordPress features. @@ -44,30 +42,36 @@ function setup() { add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in two locations. - register_nav_menus( [ - 'primary-menu' => __( 'Primary Menu', 'pressbooks-aldine' ), - 'network-footer-menu' => __( 'Footer Menu', 'pressbooks-aldine' ), - ] ); + register_nav_menus( + [ + 'primary-menu' => __( 'Primary Menu', 'pressbooks-aldine' ), + 'network-footer-menu' => __( 'Footer Menu', 'pressbooks-aldine' ), + ] + ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ - add_theme_support( 'html5', [ - 'search-form', - 'comment-form', - 'comment-list', - 'gallery', - 'caption', - ] ); + add_theme_support( + 'html5', [ + 'search-form', + 'comment-form', + 'comment-list', + 'gallery', + 'caption', + ] + ); // Set up the WordPress core custom header feature. - add_theme_support( 'custom-header', [ - 'default-image' => get_template_directory_uri() . '/dist/images/header.jpg', - 'width' => 1920, - 'height' => 884, - 'default-text-color' => '#000', - ] ); + add_theme_support( + 'custom-header', [ + 'default-image' => get_template_directory_uri() . '/dist/images/header.jpg', + 'width' => 1920, + 'height' => 884, + 'default-text-color' => '#000', + ] + ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); @@ -77,12 +81,14 @@ function setup() { * * @link https://codex.wordpress.org/Theme_Logo */ - add_theme_support( 'custom-logo', [ - 'height' => 40, - 'width' => 265, - 'flex-width' => true, - 'flex-height' => true, - ] ); + add_theme_support( + 'custom-logo', [ + 'height' => 40, + 'width' => 265, + 'flex-width' => true, + 'flex-height' => true, + ] + ); // Add editor style. add_editor_style( $assets->getPath( 'styles/editor.css' ) ); @@ -103,26 +109,30 @@ function widgets_init() { 'before_title' => '

', 'after_title' => '

', ]; - register_sidebar( [ - 'name' => __( 'Network Footer Block 1', 'pressbooks-aldine' ), - 'description' => __( - 'Add content for your network’s customizeable footer here. + register_sidebar( + [ + 'name' => __( 'Network Footer Block 1', 'pressbooks-aldine' ), + 'description' => __( + 'Add content for your network’s customizeable footer here. Currently, only text and image widgets are supported. Content in this widget area will appear in the first row (on mobile) or the first column (on desktops).', - 'aldine' - ), - 'id' => 'network-footer-block-1', - ] + $config ); - register_sidebar( [ - 'name' => __( 'Network Footer Block 2', 'pressbooks-aldine' ), - 'description' => __( - 'Add content for your network’s customizeable footer here. + 'aldine' + ), + 'id' => 'network-footer-block-1', + ] + $config + ); + register_sidebar( + [ + 'name' => __( 'Network Footer Block 2', 'pressbooks-aldine' ), + 'description' => __( + 'Add content for your network’s customizeable footer here. Currently, only text and image widgets are supported. Content in this widget area will appear in the second row (on mobile) or the middle column (on desktop).', - 'aldine' - ), - 'id' => 'network-footer-block-2', - ] + $config ); + 'aldine' + ), + 'id' => 'network-footer-block-2', + ] + $config + ); } /** @@ -216,15 +226,17 @@ function remove_admin_bar_callback() { * Hide content editor for Catalog page. */ function hide_catalog_content_editor() { - $post_id = $_GET['post'] ?? null ; + $post_id = $_GET['post'] ?? null; if ( ! isset( $post_id ) ) { return; } $pagename = get_the_title( $post_id ); if ( $pagename === 'Catalog' ) { - add_action( 'edit_form_after_title', function() { - printf( '

%s

', __( 'This page displays your network catalog, so there is no content to edit.', 'pressbooks-aldine' ) ); - } ); + add_action( + 'edit_form_after_title', function() { + printf( '

%s

', __( 'This page displays your network catalog, so there is no content to edit.', 'pressbooks-aldine' ) ); + } + ); remove_post_type_support( 'page', 'editor' ); remove_post_type_support( 'page', 'thumbnail' ); } @@ -272,7 +284,7 @@ function register_shortcode_buttons() { * @since 1.1.0 */ function tinymce_l18n() { -?> + ?> -%s', __( 'see here', 'pressbooks-aldine' ) ) ) @@ -55,6 +56,7 @@ function create_default_content() { sprintf( '

%1$s

%2$s

', sprintf( + /* translators: %1$s: link to how to page; %2$s: link to guide */ __( 'The easiest way to get started with Pressbooks is to follow our %1$s. Or, you can review our %2$s.', 'pressbooks-aldine' ), sprintf( '%s', __( '4 Step Guide to Making a Book on Pressbooks', 'pressbooks-aldine' ) ), sprintf( '%s', __( 'Guide to Using Pressbooks', 'pressbooks-aldine' ) ) @@ -79,7 +81,14 @@ function create_default_content() { foreach ( $default_pages as $slug => $page ) { $check = get_page_by_path( $slug ); if ( empty( $check ) ) { - $pages[ $slug ] = wp_insert_post( array_merge( $page, [ 'post_type' => 'page', 'post_status' => 'publish' ] ) ); + $pages[ $slug ] = wp_insert_post( + array_merge( + $page, [ + 'post_type' => 'page', + 'post_status' => 'publish', + ] + ) + ); } else { $pages[ $slug ] = $check->ID; } @@ -192,11 +201,11 @@ function assign_menus() { switch ( $id ) { case 'primary-menu': $menu = get_term_by( 'name', 'Primary Menu', 'nav_menu' ); - break; + break; case 'network-footer-menu': $menu = get_term_by( 'name', 'Footer Menu', 'nav_menu' ); - break; + break; } if ( $menu ) { diff --git a/inc/admin/namespace.php b/inc/admin/namespace.php index 109eace..84f1822 100644 --- a/inc/admin/namespace.php +++ b/inc/admin/namespace.php @@ -70,7 +70,11 @@ function catalog_column( $column, $blog_id ) { if ( 'in_catalog' === $column && ! is_main_site( $blog_id ) ) { ?> disabled="disabled" title="" /> - + disabled="disabled" title="" /> + get_setting( 'header_textcolor' )->transport = 'postMessage'; if ( isset( $wp_customize->selective_refresh ) ) { - $wp_customize->selective_refresh->add_partial( 'blogname', [ - 'selector' => '.site-title a', - 'render_callback' => function() { - bloginfo( 'name' ); - }, - ] ); - $wp_customize->selective_refresh->add_partial( 'blogdescription', [ - 'selector' => '.site-description', - 'render_callback' => function() { - bloginfo( 'description' ); - }, - ] ); - $wp_customize->selective_refresh->add_partial( 'pb_front_page_catalog_title', [ - 'selector' => '#latest-books-title', - 'render_callback' => function() { - get_option( 'pb_front_page_catalog_title' ); - }, - ] ); - $wp_customize->selective_refresh->add_partial( 'pb_network_contact_form_title', [ - 'selector' => '#contact .contact__title', - 'render_callback' => function() { - get_option( 'pb_network_contact_form_title' ); - }, - ] ); + $wp_customize->selective_refresh->add_partial( + 'blogname', [ + 'selector' => '.site-title a', + 'render_callback' => function() { + bloginfo( 'name' ); + }, + ] + ); + $wp_customize->selective_refresh->add_partial( + 'blogdescription', [ + 'selector' => '.site-description', + 'render_callback' => function() { + bloginfo( 'description' ); + }, + ] + ); + $wp_customize->selective_refresh->add_partial( + 'pb_front_page_catalog_title', [ + 'selector' => '#latest-books-title', + 'render_callback' => function() { + get_option( 'pb_front_page_catalog_title' ); + }, + ] + ); + $wp_customize->selective_refresh->add_partial( + 'pb_network_contact_form_title', [ + 'selector' => '#contact .contact__title', + 'render_callback' => function() { + get_option( 'pb_network_contact_form_title' ); + }, + ] + ); } foreach ( [ @@ -92,103 +100,141 @@ function customize_register( \WP_Customize_Manager $wp_customize ) { 'description' => __( 'Used for text on an accent color background.', 'pressbooks-aldine' ), ], ] as $color ) { - $wp_customize->add_setting("pb_network_color_{$color['slug']}", [ - 'type' => 'option', - 'default' => $color['hex'], - ]); - $wp_customize->add_control(new \WP_Customize_Color_Control( - $wp_customize, - "pb_network_color_{$color['slug']}", - [ - 'label' => $color['label'], - 'section' => 'colors', - 'description' => $color['description'], - 'settings' => "pb_network_color_{$color['slug']}", + $wp_customize->add_setting( + "pb_network_color_{$color['slug']}", [ + 'type' => 'option', + 'default' => $color['hex'], ] - )); + ); + $wp_customize->add_control( + new \WP_Customize_Color_Control( + $wp_customize, + "pb_network_color_{$color['slug']}", + [ + 'label' => $color['label'], + 'section' => 'colors', + 'description' => $color['description'], + 'settings' => "pb_network_color_{$color['slug']}", + ] + ) + ); } - $wp_customize->add_section('pb_network_social', [ - 'title' => __( 'Social Media', 'pressbooks-aldine' ), - 'priority' => 30, - ]); - $wp_customize->add_setting('pb_network_facebook', [ - 'type' => 'option', - 'sanitize_callback' => 'esc_url_raw', - ]); - $wp_customize->add_control('pb_network_facebook', [ - 'label' => __( 'Facebook', 'pressbooks-aldine' ), - 'section' => 'pb_network_social', - 'settings' => 'pb_network_facebook', - ]); - $wp_customize->add_setting('pb_network_twitter', [ - 'type' => 'option', - 'sanitize_callback' => 'esc_url_raw', - ]); - $wp_customize->add_control('pb_network_twitter', [ - 'label' => __( 'Twitter', 'pressbooks-aldine' ), - 'section' => 'pb_network_social', - 'settings' => 'pb_network_twitter', - ]); + $wp_customize->add_section( + 'pb_network_social', [ + 'title' => __( 'Social Media', 'pressbooks-aldine' ), + 'priority' => 30, + ] + ); + $wp_customize->add_setting( + 'pb_network_facebook', [ + 'type' => 'option', + 'sanitize_callback' => 'esc_url_raw', + ] + ); + $wp_customize->add_control( + 'pb_network_facebook', [ + 'label' => __( 'Facebook', 'pressbooks-aldine' ), + 'section' => 'pb_network_social', + 'settings' => 'pb_network_facebook', + ] + ); + $wp_customize->add_setting( + 'pb_network_twitter', [ + 'type' => 'option', + 'sanitize_callback' => 'esc_url_raw', + ] + ); + $wp_customize->add_control( + 'pb_network_twitter', [ + 'label' => __( 'Twitter', 'pressbooks-aldine' ), + 'section' => 'pb_network_social', + 'settings' => 'pb_network_twitter', + ] + ); if ( defined( 'PB_PLUGIN_VERSION' ) ) { - $wp_customize->add_section('pb_front_page_catalog', [ - 'title' => __( 'Front Page Catalog', 'pressbooks-aldine' ), + $wp_customize->add_section( + 'pb_front_page_catalog', [ + 'title' => __( 'Front Page Catalog', 'pressbooks-aldine' ), + 'priority' => 25, + ] + ); + $wp_customize->add_setting( + 'pb_front_page_catalog', [ + 'type' => 'option', + ] + ); + $wp_customize->add_control( + 'pb_front_page_catalog', [ + 'label' => __( 'Show Front Page Catalog', 'pressbooks-aldine' ), + 'section' => 'pb_front_page_catalog', + 'settings' => 'pb_front_page_catalog', + 'type' => 'checkbox', + ] + ); + $wp_customize->add_setting( + 'pb_front_page_catalog_title', [ + 'type' => 'option', + 'sanitize_callback' => 'sanitize_text_field', + 'default' => __( 'Our Latest Titles', 'pressbooks-aldine' ), + ] + ); + $wp_customize->add_control( + 'pb_front_page_catalog_title', [ + 'label' => __( 'Front Page Catalog Title', 'pressbooks-aldine' ), + 'section' => 'pb_front_page_catalog', + 'settings' => 'pb_front_page_catalog_title', + ] + ); + } + + $wp_customize->add_section( + 'pb_network_contact_form', [ + 'title' => __( 'Contact Form', 'pressbooks-aldine' ), 'priority' => 25, - ]); - $wp_customize->add_setting('pb_front_page_catalog', [ + ] + ); + $wp_customize->add_setting( + 'pb_network_contact_form', [ 'type' => 'option', - ]); - $wp_customize->add_control('pb_front_page_catalog', [ - 'label' => __( 'Show Front Page Catalog', 'pressbooks-aldine' ), - 'section' => 'pb_front_page_catalog', - 'settings' => 'pb_front_page_catalog', + ] + ); + $wp_customize->add_control( + 'pb_network_contact_form', [ + 'label' => __( 'Show Contact Form', 'pressbooks-aldine' ), + 'section' => 'pb_network_contact_form', + 'settings' => 'pb_network_contact_form', 'type' => 'checkbox', - ]); - $wp_customize->add_setting('pb_front_page_catalog_title', [ + ] + ); + $wp_customize->add_setting( + 'pb_network_contact_form_title', [ 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field', - 'default' => __( 'Our Latest Titles', 'pressbooks-aldine' ), - ]); - $wp_customize->add_control('pb_front_page_catalog_title', [ - 'label' => __( 'Front Page Catalog Title', 'pressbooks-aldine' ), - 'section' => 'pb_front_page_catalog', - 'settings' => 'pb_front_page_catalog_title', - ]); - } - - $wp_customize->add_section('pb_network_contact_form', [ - 'title' => __( 'Contact Form', 'pressbooks-aldine' ), - 'priority' => 25, - ]); - $wp_customize->add_setting('pb_network_contact_form', [ - 'type' => 'option', - ]); - $wp_customize->add_control('pb_network_contact_form', [ - 'label' => __( 'Show Contact Form', 'pressbooks-aldine' ), - 'section' => 'pb_network_contact_form', - 'settings' => 'pb_network_contact_form', - 'type' => 'checkbox', - ]); - $wp_customize->add_setting('pb_network_contact_form_title', [ - 'type' => 'option', - 'sanitize_callback' => 'sanitize_text_field', - 'default' => __( 'Contact Us', 'pressbooks-aldine' ), - ]); - $wp_customize->add_control('pb_network_contact_form_title', [ - 'label' => __( 'Contact Form Title', 'pressbooks-aldine' ), - 'section' => 'pb_network_contact_form', - 'settings' => 'pb_network_contact_form_title', - ]); - $wp_customize->add_setting('pb_network_contact_email', [ - 'type' => 'option', - 'default' => get_option( 'admin_email', '' ), - 'sanitize_callback' => 'sanitize_email', - ]); - $wp_customize->add_control('pb_network_contact_email', [ - 'label' => __( 'Contact Email', 'pressbooks-aldine' ), - 'section' => 'pb_network_contact_form', - 'settings' => 'pb_network_contact_email', - ]); + 'default' => __( 'Contact Us', 'pressbooks-aldine' ), + ] + ); + $wp_customize->add_control( + 'pb_network_contact_form_title', [ + 'label' => __( 'Contact Form Title', 'pressbooks-aldine' ), + 'section' => 'pb_network_contact_form', + 'settings' => 'pb_network_contact_form_title', + ] + ); + $wp_customize->add_setting( + 'pb_network_contact_email', [ + 'type' => 'option', + 'default' => get_option( 'admin_email', '' ), + 'sanitize_callback' => 'sanitize_email', + ] + ); + $wp_customize->add_control( + 'pb_network_contact_email', [ + 'label' => __( 'Contact Email', 'pressbooks-aldine' ), + 'section' => 'pb_network_contact_form', + 'settings' => 'pb_network_contact_email', + ] + ); } /** diff --git a/inc/filters/namespace.php b/inc/filters/namespace.php index 1eef590..1273614 100644 --- a/inc/filters/namespace.php +++ b/inc/filters/namespace.php @@ -7,8 +7,8 @@ namespace Aldine\Filters; -use PressbooksMix\Assets; use function Aldine\Helpers\has_sections; +use PressbooksMix\Assets; /** * Adds custom classes to the array of body classes. @@ -32,9 +32,11 @@ function body_classes( array $classes ) { } /** Clean up class names for custom templates */ - $classes = array_map( function ( $class ) { - return preg_replace( [ '/-php$/', '/^page-template-views/' ], '', $class ); - }, $classes ); + $classes = array_map( + function ( $class ) { + return preg_replace( [ '/-php$/', '/^page-template-views/' ], '', $class ); + }, $classes + ); return array_filter( $classes ); } diff --git a/inc/helpers/namespace.php b/inc/helpers/namespace.php index f74abe0..547458e 100644 --- a/inc/helpers/namespace.php +++ b/inc/helpers/namespace.php @@ -7,8 +7,8 @@ namespace Aldine\Helpers; -use Pressbooks\Book; use function \Pressbooks\Metadata\book_information_to_schema; +use Pressbooks\Book; /** * @param int $page @@ -22,7 +22,10 @@ use function \Pressbooks\Metadata\book_information_to_schema; function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $license = '', $subject = '' ) { if ( ! defined( 'PB_PLUGIN_VERSION' ) ) { - return [ 'pages' => 0, 'books' => [] ]; // Bail + return [ + 'pages' => 0, + 'books' => [], + ]; // Bail } /** @@ -91,7 +94,10 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen } } - return [ 'pages' => $total_pages, 'books' => $books ]; + return [ + 'pages' => $total_pages, + 'books' => $books, + ]; } @@ -226,9 +232,11 @@ function default_menu( $args = [], $items = '' ) { get_default_menu( $items ) ); if ( class_exists( '\PressbooksOAuth\OAuth' ) ) { - add_filter( 'pb_oauth_output_button', function( $bool ) { - return false; - } ); + add_filter( + 'pb_oauth_output_button', function( $bool ) { + return false; + } + ); do_action( 'pressbooks_oauth_connect' ); } } @@ -279,6 +287,7 @@ function handle_contact_form_submission() { } else { $sent = wp_mail( $contact_email, + /* translators: %s name of contact for submitter */ sprintf( __( 'Contact Form Submission from %s', 'pressbooks-aldine' ), $name ), sprintf( "From: %1\$s <%2\$s>\nInstitution: %3\$s\n\n%4\$s", diff --git a/inc/intervention.php b/inc/intervention.php index 9d2ed05..666befc 100644 --- a/inc/intervention.php +++ b/inc/intervention.php @@ -11,30 +11,34 @@ intervention( 'remove-customizer-items', 'static-front-page', 'all' ); intervention( 'remove-emoji' ); intervention( 'remove-howdy', __( 'Hello,', 'pressbooks-aldine' ) ); intervention( 'remove-dashboard-items', [ 'activity', 'quick-draft' ] ); -intervention( 'remove-menu-items', [ - 'posts', - 'tool-import', - 'tool-export', - 'setting-writing', - 'setting-reading', - 'setting-permalink', -], 'all' ); -intervention( 'remove-widgets', [ - 'pages', - 'calendar', - 'archives', - 'links', - 'media-audio', - 'meta', - 'search', - 'categories', - 'recent-posts', - 'recent-comments', - 'rss', - 'tag-cloud', - 'custom-menu', - 'custom-html', - 'media-video', - 'akismet', -], 'all' ); +intervention( + 'remove-menu-items', [ + 'posts', + 'tool-import', + 'tool-export', + 'setting-writing', + 'setting-reading', + 'setting-permalink', + ], 'all' +); +intervention( + 'remove-widgets', [ + 'pages', + 'calendar', + 'archives', + 'links', + 'media-audio', + 'meta', + 'search', + 'categories', + 'recent-posts', + 'recent-comments', + 'rss', + 'tag-cloud', + 'custom-menu', + 'custom-html', + 'media-video', + 'akismet', + ], 'all' +); intervention( 'remove-toolbar-frontend', 'all' ); diff --git a/index.php b/index.php index c7b8d50..772becb 100644 --- a/index.php +++ b/index.php @@ -20,16 +20,18 @@ get_header(); ?> + if ( is_home() && ! is_front_page() ) : + ?>

- get_template_part( 'template-parts/content', 'none' ); - endif; ?> + endif; + ?>
diff --git a/page-catalog.php b/page-catalog.php index c1669f6..a16ed35 100644 --- a/page-catalog.php +++ b/page-catalog.php @@ -9,10 +9,10 @@ * @package Aldine */ +use function Aldine\Helpers\get_available_licenses; +use function Aldine\Helpers\get_available_subjects; use function Aldine\Helpers\get_catalog_data; use function Aldine\Helpers\get_catalog_licenses; -use function Aldine\Helpers\get_available_subjects; -use function Aldine\Helpers\get_available_licenses; $current_page = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $orderby = ( get_query_var( 'orderby' ) ) ? get_query_var( 'orderby' ) : 'title'; @@ -38,9 +38,9 @@ if ( ! empty( $catalog_data['books'] ) ) : -
- else : - while ( have_posts() ) : the_post(); + while ( have_posts() ) : + the_post(); get_template_part( 'partials/content', 'page' ); diff --git a/partials/book.php b/partials/book.php index 1f6210a..4445ace 100644 --- a/partials/book.php +++ b/partials/book.php @@ -1,29 +1,38 @@ -
  • data-date-published="" + + data-date-published="" data-license="getLicenseFromUrl( $book['metadata']['license']['url'] ); ?>" - data-subject="" + + data-subject="" > -

    +

    - +

    - */ ?> + */ + ?> -

    +

    "> -

    +

    -

    +

  • diff --git a/partials/contact-form.php b/partials/contact-form.php index e8d339a..67f7e10 100644 --- a/partials/contact-form.php +++ b/partials/contact-form.php @@ -23,33 +23,65 @@ $contact_form_response = \Aldine\Helpers\handle_contact_form_submission();

    - class="error" type="text" name="visitor_name" value="" required> + + class="error" type="text" name="visitor_name" value=" + + " required>

    - class="error" type="email" name="visitor_email" value="" required> + + class="error" type="email" name="visitor_email" value=" + + " required>

    - class="error" type="text" name="visitor_institution" value="" required> + + class="error" type="text" name="visitor_institution" value=" + + " required>

    - + diff --git a/partials/content-front-page.php b/partials/content-front-page.php index a33eca6..95d3c50 100644 --- a/partials/content-front-page.php +++ b/partials/content-front-page.php @@ -55,13 +55,22 @@ if ( get_option( 'pb_front_page_catalog' ) ) {

    -
    data-next-page=""> +
    + data-next-page="">
      - + endforeach; + ?>
    - +
    + if ( is_home() && current_user_can( 'publish_posts' ) ) : + ?> -

    +

    + ?> +

    @@ -39,12 +42,14 @@ + else : + ?>

    + endif; + ?>
    diff --git a/partials/content-page-catalog.php b/partials/content-page-catalog.php index e8a4263..6aae9a8 100644 --- a/partials/content-page-catalog.php +++ b/partials/content-page-catalog.php @@ -18,15 +18,19 @@ >
    - $val ) : - if ( array_key_exists( $key, $available_subjects ) ) : ?> + $val ) : + if ( array_key_exists( $key, $available_subjects ) ) : + ?>

    - $v ) : - if ( in_array( $k, $available_subjects[ $key ], true ) ) : ?> + $v ) : + if ( in_array( $k, $available_subjects[ $key ], true ) ) : + ?> > - - + +
    @@ -35,12 +39,16 @@

    > - $value ) : - if ( in_array( $key, $available_licenses, true ) ) : ?> + $value ) : + if ( in_array( $key, $available_licenses, true ) ) : + ?> > - +

    @@ -50,7 +58,8 @@ 'subject' => __( 'Subject', 'pressbooks-aldine' ), 'latest' => __( 'Latest', 'pressbooks-aldine' ), ]; - foreach ( $sorts as $key => $value ) { ?> + foreach ( $sorts as $key => $value ) { + ?> > @@ -59,26 +68,36 @@
      - + endforeach; + ?>
    1 ) : ?>
    diff --git a/partials/content.php b/partials/content.php index 4ca20eb..31d2ab2 100644 --- a/partials/content.php +++ b/partials/content.php @@ -18,34 +18,40 @@ the_title( '

    ', '

    ' ); endif; - if ( 'post' === get_post_type() ) : ?> + if ( 'post' === get_post_type() ) : + ?> - +
    "%s"', 'pressbooks-aldine' ), - [ - 'span' => [ - 'class' => [], - ], - ] - ), - get_the_title() - ) ); + the_content( + sprintf( + wp_kses( + /* translators: %s: Name of current post. Only visible to screen readers */ + __( 'Continue reading "%s"', 'pressbooks-aldine' ), + [ + 'span' => [ + 'class' => [], + ], + ] + ), + get_the_title() + ) + ); - wp_link_pages( [ - 'before' => '', - ] ); - ?> + wp_link_pages( + [ + 'before' => '', + ] + ); + ?>