Closes the three problems that blocked the consolidation and records the rest
as tasks.
Licence: GPLv2 or later (WordPress.org compatible)
LICENSE is now the full GPLv2 text and NOTICE is gone (it was Apache
specific). All 101 SPDX headers read GPL-2.0-or-later and every shipped
header says "GPLv2 or later".
This also fixes an inconsistency that predated the consolidation: the theme's
style.css declared GPLv2 while its PHP files carried Apache headers.
Old/ and archive/pre-umbra-releases/ keep their original Apache headers on
purpose -- they are frozen snapshots, not shipped code.
Schema: the catalogue schema is canonical for bd_books and bd_series
Adds Umbra_Schema_Migration. The catalogue and library modules previously
both created those two tables with different columns, so whichever plugin
activated first won and the other read and wrote against the wrong shape.
The migration detects a library-shaped table, RENAMES it aside (never drops
it), creates the canonical table and copies rows across:
- book IDs preserved, keeping bd_book_meta, bd_reviews, bd_ratings and
bd_review_shortlinks valid
- title/slug/description resolved from the linked post
- the library's single isbn/asin land on the ebook columns; amazon_asin is
also set so existing product links keep working
- series migrated first so books.series_id still resolves
- post linkage rewritten as _bd_bookshelf_book_id (preserved meta key)
- publish_date kept as _bd_bookshelf_publish_date (no catalogue column)
- bd_ratings goodreads/amazon folded into rating_goodreads/rating_amazon
- rows whose post is gone are skipped with a log line, not turned into
unusable books
- duplicate slugs de-duplicated, since catalogue slug is UNIQUE
It runs before dbDelta, and on admin_init as well as activation, because
plugin updates do not re-run activation hooks. Ordering matters: dbDelta adds
columns but never drops them, so pointed at a library-shaped table it would
graft on catalogue columns and leave a table satisfying neither schema.
Umbra_Bookshelf_Helper_Install no longer creates bd_books or bd_series.
Scraping: Goodreads only, one implementation
There were three Goodreads implementations and two Amazon ones; both library
"scrapers" were empty stubs attached to cron events that fired on schedule to
do nothing, and both real scraper classes were never called at all.
Umbra_Amazon_Scraper is deleted and the duplicate HTML parsing is gone from
Umbra_Rating_Sync, which now delegates to Umbra_Goodreads_Scraper. The two
library stubs and their cron registrations are removed. One schedule
survives: bd_bookshelf_sync_ratings, every 12 hours.
The rating_amazon column is retained (it holds data and is populated during
migration) and Amazon retail links are unaffected.
A new rating fetch failure keeps the last known value instead of writing zero.
The admin ratings notice no longer warns about Amazon scraping.
Umbra_SEO is now instantiated
It registers its hooks from a constructor and the bootstrap never constructed
it, so the class was dead code and no SEO output was produced. Its meta, Open
Graph, Twitter card and sitemap hooks now attach. Completing SEO for generated
book detail pages is docs/TASKS.md #2.
Assets that 404'd
- assets/images/default-cover.png now holds a real 512x815 cover
(WorkingTitleCover_512x815.png). The helper returned this path but the
repository contained no images at all.
- email/assets/js/admin.js is committed as an empty placeholder. It was
enqueued on every email admin page but had never been committed.
Tests
- tests/schema_migration_test.php: 42 checks against a real database, driven
through the sqlite3 CLI on a throwaway file. Covers shape detection, row
mapping, ID preservation, orphan handling, rating folding, idempotency and
slug collisions.
- tests/run_all.sh runs every suite.
- The declared version is now checked against the plugin header rather than a
literal, so a version bump cannot silently break the suite.
Docs
- KNOWN-ISSUES.md rewritten: three resolved, three remaining.
- TASKS.md added: email admin behaviour, book detail page SEO, batching the
rating sync, reclaiming legacy tables, reconciling the two book models,
retiring the Old/ archive.
- SPEC and ARCHITECTURE updated for schema ownership, the migration ordering
constraint, and the single scraper.
Version 1.1.0.
289 lines
9.4 KiB
PHP
289 lines
9.4 KiB
PHP
<?php
|
|
// Copyright 2026 Umbra Tools (umbratools.com)
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
/**
|
|
* Customizer Settings
|
|
*
|
|
* @package BD_Murphy
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Add Customizer settings
|
|
*
|
|
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
|
*/
|
|
function bdm_customize_register($wp_customize) {
|
|
|
|
// Colors Panel
|
|
$wp_customize->add_panel('bdm_colors', array(
|
|
'title' => esc_html__('Colors', 'bd-bookshelf'),
|
|
'priority' => 30,
|
|
));
|
|
|
|
$wp_customize->add_section('bdm_primary_colors', array(
|
|
'title' => esc_html__('Primary Colors', 'bd-bookshelf'),
|
|
'panel' => 'bdm_colors',
|
|
));
|
|
|
|
// Primary Color
|
|
$wp_customize->add_setting('primary_color', array(
|
|
'default' => '#1B3A6B',
|
|
'sanitize_callback' => 'sanitize_hex_color',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control(new WP_Customize_Color_Control(
|
|
$wp_customize,
|
|
'primary_color',
|
|
array(
|
|
'label' => esc_html__('Primary Color (Navy)', 'bd-bookshelf'),
|
|
'section' => 'bdm_primary_colors',
|
|
)
|
|
));
|
|
|
|
// Accent Color
|
|
$wp_customize->add_setting('accent_color', array(
|
|
'default' => '#C8A96E',
|
|
'sanitize_callback' => 'sanitize_hex_color',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control(new WP_Customize_Color_Control(
|
|
$wp_customize,
|
|
'accent_color',
|
|
array(
|
|
'label' => esc_html__('Accent Color (Gold)', 'bd-bookshelf'),
|
|
'section' => 'bdm_primary_colors',
|
|
)
|
|
));
|
|
|
|
// Typography Panel
|
|
$wp_customize->add_panel('bdm_typography', array(
|
|
'title' => esc_html__('Typography', 'bd-bookshelf'),
|
|
'priority' => 35,
|
|
));
|
|
|
|
// Heading Fonts Section
|
|
$wp_customize->add_section('bdm_heading_fonts', array(
|
|
'title' => esc_html__('Headings', 'bd-bookshelf'),
|
|
'panel' => 'bdm_typography',
|
|
));
|
|
|
|
$heading_fonts = array(
|
|
'Playfair Display' => 'Playfair Display',
|
|
'Merriweather' => 'Merriweather',
|
|
'Libre Baskerville'=> 'Libre Baskerville',
|
|
'Lora' => 'Lora',
|
|
'Georgia' => 'Georgia',
|
|
);
|
|
|
|
$wp_customize->add_setting('heading_font', array(
|
|
'default' => 'Playfair Display',
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control('heading_font', array(
|
|
'label' => esc_html__('Heading Font', 'bd-bookshelf'),
|
|
'section' => 'bdm_heading_fonts',
|
|
'type' => 'select',
|
|
'choices' => $heading_fonts,
|
|
));
|
|
|
|
// Body Fonts Section
|
|
$wp_customize->add_section('bdm_body_fonts', array(
|
|
'title' => esc_html__('Body', 'bd-bookshelf'),
|
|
'panel' => 'bdm_typography',
|
|
));
|
|
|
|
$body_fonts = array(
|
|
'Lato' => 'Lato',
|
|
'Open Sans' => 'Open Sans',
|
|
'Source Sans Pro'=> 'Source Sans Pro',
|
|
'Roboto' => 'Roboto',
|
|
'Calibri' => 'Calibri',
|
|
);
|
|
|
|
$wp_customize->add_setting('body_font', array(
|
|
'default' => 'Lato',
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control('body_font', array(
|
|
'label' => esc_html__('Body Font', 'bd-bookshelf'),
|
|
'section' => 'bdm_body_fonts',
|
|
'type' => 'select',
|
|
'choices' => $body_fonts,
|
|
));
|
|
|
|
// Social Sharing Section
|
|
$wp_customize->add_section('bdm_social_sharing', array(
|
|
'title' => esc_html__('Social Sharing', 'bd-bookshelf'),
|
|
'priority' => 60,
|
|
));
|
|
|
|
// Facebook
|
|
$wp_customize->add_setting('share_facebook', array(
|
|
'default' => true,
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
));
|
|
|
|
$wp_customize->add_control('share_facebook', array(
|
|
'label' => esc_html__('Show Facebook', 'bd-bookshelf'),
|
|
'section' => 'bdm_social_sharing',
|
|
'type' => 'checkbox',
|
|
));
|
|
|
|
// X/Twitter
|
|
$wp_customize->add_setting('share_twitter', array(
|
|
'default' => true,
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
));
|
|
|
|
$wp_customize->add_control('share_twitter', array(
|
|
'label' => esc_html__('Show X/Twitter', 'bd-bookshelf'),
|
|
'section' => 'bdm_social_sharing',
|
|
'type' => 'checkbox',
|
|
));
|
|
|
|
// LinkedIn
|
|
$wp_customize->add_setting('share_linkedin', array(
|
|
'default' => true,
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
));
|
|
|
|
$wp_customize->add_control('share_linkedin', array(
|
|
'label' => esc_html__('Show LinkedIn', 'bd-bookshelf'),
|
|
'section' => 'bdm_social_sharing',
|
|
'type' => 'checkbox',
|
|
));
|
|
|
|
// WhatsApp
|
|
$wp_customize->add_setting('share_whatsapp', array(
|
|
'default' => true,
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
));
|
|
|
|
$wp_customize->add_control('share_whatsapp', array(
|
|
'label' => esc_html__('Show WhatsApp', 'bd-bookshelf'),
|
|
'section' => 'bdm_social_sharing',
|
|
'type' => 'checkbox',
|
|
));
|
|
|
|
// Author Book Settings Section
|
|
$wp_customize->add_section('bdm_book_settings', array(
|
|
'title' => esc_html__('Author Book Settings', 'bd-bookshelf'),
|
|
'priority' => 50,
|
|
));
|
|
|
|
// Author Name
|
|
$wp_customize->add_setting('author_name', array(
|
|
'default' => 'B.D. Murphy',
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control('author_name', array(
|
|
'label' => esc_html__('Author Name', 'bd-bookshelf'),
|
|
'description' => esc_html__('Your author/pen name to display in widgets', 'bd-bookshelf'),
|
|
'section' => 'bdm_book_settings',
|
|
'type' => 'text',
|
|
));
|
|
|
|
// Goodreads Author ID
|
|
$wp_customize->add_setting('goodreads_author_id', array(
|
|
'default' => '30469651',
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control('goodreads_author_id', array(
|
|
'label' => esc_html__('Goodreads Author ID', 'bd-bookshelf'),
|
|
'description' => esc_html__('Your Goodreads author page ID. Default: 30469651 (B.D. Murphy)', 'bd-bookshelf'),
|
|
'section' => 'bdm_book_settings',
|
|
'type' => 'text',
|
|
));
|
|
|
|
// Amazon Author Central ID
|
|
$wp_customize->add_setting('amazon_author_id', array(
|
|
'default' => '30469651',
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control('amazon_author_id', array(
|
|
'label' => esc_html__('Amazon Author Central Author ID', 'bd-bookshelf'),
|
|
'description' => esc_html__('Enter your Amazon Author Central author page ID', 'bd-bookshelf'),
|
|
'section' => 'bdm_book_settings',
|
|
'type' => 'text',
|
|
));
|
|
|
|
|
|
// ============================================
|
|
// Display Options Section
|
|
// ============================================
|
|
$wp_customize->add_section('bdm_display_options', array(
|
|
'title' => esc_html__('Display Options', 'bd-bookshelf'),
|
|
'priority' => 55,
|
|
));
|
|
|
|
// Show Newsletter Signup
|
|
$wp_customize->add_setting('show_newsletter_signup', array(
|
|
'default' => true,
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control('show_newsletter_signup', array(
|
|
'label' => esc_html__('Show Newsletter Signup Section', 'bd-bookshelf'),
|
|
'description' => esc_html__('Display the newsletter signup box on the About page sidebar', 'bd-bookshelf'),
|
|
'section' => 'bdm_display_options',
|
|
'type' => 'checkbox',
|
|
));
|
|
|
|
// Show Sign Up for Updates Link
|
|
$wp_customize->add_setting('show_signup_link', array(
|
|
'default' => true,
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control('show_signup_link', array(
|
|
'label' => esc_html__('Show "Sign Up for Updates" Link', 'bd-bookshelf'),
|
|
'description' => esc_html__('Display the sign-up link in the About page and footer', 'bd-bookshelf'),
|
|
'section' => 'bdm_display_options',
|
|
'type' => 'checkbox',
|
|
));
|
|
|
|
// Enable Goodreads Remote Fetching
|
|
$wp_customize->add_setting('enable_goodreads_fetch', array(
|
|
'default' => false,
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
'transport' => 'refresh',
|
|
));
|
|
|
|
$wp_customize->add_control('enable_goodreads_fetch', array(
|
|
'label' => esc_html__('Enable Goodreads Integration', 'bd-bookshelf'),
|
|
'description' => esc_html__('Allow the theme to fetch book data from Goodreads. This sends data to a third-party service. Disable if you prefer not to share data with Goodreads.', 'bd-bookshelf'),
|
|
'section' => 'bdm_display_options',
|
|
'type' => 'checkbox',
|
|
));
|
|
}
|
|
add_action('customize_register', 'bdm_customize_register');
|
|
|
|
/**
|
|
* Sanitize checkbox
|
|
*
|
|
* @param mixed $checked Checked value.
|
|
* @return bool
|
|
*/
|
|
function bdm_sanitize_checkbox($checked) {
|
|
return ((isset($checked) && true === $checked) ? true : false);
|
|
}
|