Fix typography CSS: wrong selector + overly restrictive meta gate
CSS targeted .post-content but the theme template uses .entry-content. Also removed the _prautoblogger_generated meta check — display settings should apply site-wide to all posts, not just PRAutoBlogger-generated ones. Bump 0.7.0 → 0.7.1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
||||
/**
|
||||
* Injects frontend typography and table styles for PRAutoBlogger-generated posts.
|
||||
*
|
||||
* What: Outputs inline CSS on single post pages that have the
|
||||
* _prautoblogger_generated meta flag, applying user-configured
|
||||
* font family, font size, and table border styles.
|
||||
* What: Outputs inline CSS on all single post pages, applying
|
||||
* user-configured font family, font size, and table border
|
||||
* styles from the Display admin settings.
|
||||
* Who calls it: PRAutoBlogger::register_frontend_hooks() hooks this
|
||||
* into wp_head.
|
||||
* Dependencies: Reads wp_options for typography settings.
|
||||
@@ -27,10 +27,10 @@ class PRAutoBlogger_Article_Typography {
|
||||
private const OPT_TABLE_BORDERS = 'prautoblogger_table_borders';
|
||||
|
||||
/**
|
||||
* Output inline CSS in <head> for PRAutoBlogger posts.
|
||||
* Output inline CSS in <head> for single post pages.
|
||||
*
|
||||
* Only outputs on singular post pages generated by PRAutoBlogger.
|
||||
* The CSS targets .post-content (PR Theme's article body class)
|
||||
* Applies to all posts — typography settings are site-wide.
|
||||
* The CSS targets .entry-content (PR Theme's article body class)
|
||||
* and overrides the theme's CSS custom properties so the cascade
|
||||
* works naturally with headings and sub-elements.
|
||||
*
|
||||
@@ -43,11 +43,6 @@ class PRAutoBlogger_Article_Typography {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id = get_queried_object_id();
|
||||
if ( '1' !== get_post_meta( $post_id, '_prautoblogger_generated', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css = $this->build_css();
|
||||
if ( '' === $css ) {
|
||||
return;
|
||||
@@ -73,7 +68,7 @@ class PRAutoBlogger_Article_Typography {
|
||||
$font_family = $this->get_font_family_stack();
|
||||
if ( '' !== $font_family ) {
|
||||
$rules[] = sprintf(
|
||||
".post-content,\n.post-content p,\n.post-content li {\n\tfont-family: %s;\n}",
|
||||
".entry-content,\n.entry-content p,\n.entry-content li {\n\tfont-family: %s;\n}",
|
||||
$font_family
|
||||
);
|
||||
}
|
||||
@@ -81,7 +76,7 @@ class PRAutoBlogger_Article_Typography {
|
||||
$font_size = absint( get_option( self::OPT_FONT_SIZE, 0 ) );
|
||||
if ( $font_size > 0 ) {
|
||||
$rules[] = sprintf(
|
||||
".post-content,\n.post-content p,\n.post-content li {\n\tfont-size: %dpx;\n\tline-height: 1.7;\n}",
|
||||
".entry-content,\n.entry-content p,\n.entry-content li {\n\tfont-size: %dpx;\n\tline-height: 1.7;\n}",
|
||||
$font_size
|
||||
);
|
||||
}
|
||||
@@ -89,22 +84,22 @@ class PRAutoBlogger_Article_Typography {
|
||||
$table_borders = get_option( self::OPT_TABLE_BORDERS, '1' );
|
||||
if ( '1' === $table_borders ) {
|
||||
$rules[] = implode( "\n", [
|
||||
'.post-content table {',
|
||||
'.entry-content table {',
|
||||
"\tborder-collapse: collapse;",
|
||||
"\twidth: 100%;",
|
||||
"\tmargin: 1.5em 0;",
|
||||
'}',
|
||||
'.post-content th,',
|
||||
'.post-content td {',
|
||||
'.entry-content th,',
|
||||
'.entry-content td {',
|
||||
"\tborder: 1px solid #d1d5db;",
|
||||
"\tpadding: 0.6em 1em;",
|
||||
"\ttext-align: left;",
|
||||
'}',
|
||||
'.post-content thead th {',
|
||||
'.entry-content thead th {',
|
||||
"\tbackground: #f3f4f6;",
|
||||
"\tfont-weight: 600;",
|
||||
'}',
|
||||
'.post-content tbody tr:nth-child(even) {',
|
||||
'.entry-content tbody tr:nth-child(even) {',
|
||||
"\tbackground: #f9fafb;",
|
||||
'}',
|
||||
] );
|
||||
@@ -158,7 +153,7 @@ class PRAutoBlogger_Article_Typography {
|
||||
/**
|
||||
* Enqueue Google Fonts stylesheet when a web font is selected.
|
||||
*
|
||||
* Only loads on singular PRAutoBlogger posts that use a Google-hosted font.
|
||||
* Only loads on singular post pages that use a Google-hosted font.
|
||||
*
|
||||
* Side effects: enqueues a remote stylesheet.
|
||||
*
|
||||
@@ -169,11 +164,6 @@ class PRAutoBlogger_Article_Typography {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id = get_queried_object_id();
|
||||
if ( '1' !== get_post_meta( $post_id, '_prautoblogger_generated', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$font = sanitize_text_field( get_option( self::OPT_FONT_FAMILY, 'default' ) );
|
||||
|
||||
// Map font keys to Google Fonts URLs. Inter is already loaded by the theme.
|
||||
|
||||
Reference in New Issue
Block a user