From 5f81b78d5132c23c796cef11cd952220fd84eb9f Mon Sep 17 00:00:00 2001 From: Takshil Kunadia Date: Thu, 27 Feb 2025 15:30:06 +0530 Subject: [PATCH 1/7] feat(corrections-blocks): add Correction Box block --- includes/class-blocks.php | 6 ++ src/blocks/correction-box/block.json | 43 ++++++++ .../class-correction-box-block.php | 100 ++++++++++++++++++ src/blocks/correction-box/edit.jsx | 78 ++++++++++++++ src/blocks/correction-box/index.js | 39 +++++++ src/blocks/correction-box/style.scss | 10 ++ src/blocks/index.js | 9 +- webpack.config.js | 7 ++ 8 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 src/blocks/correction-box/block.json create mode 100644 src/blocks/correction-box/class-correction-box-block.php create mode 100644 src/blocks/correction-box/edit.jsx create mode 100644 src/blocks/correction-box/index.js create mode 100644 src/blocks/correction-box/style.scss diff --git a/includes/class-blocks.php b/includes/class-blocks.php index a315a121af..3c601794ee 100644 --- a/includes/class-blocks.php +++ b/includes/class-blocks.php @@ -18,6 +18,11 @@ final class Blocks { */ public static function init() { require_once NEWSPACK_ABSPATH . 'src/blocks/reader-registration/index.php'; + + if ( class_exists( 'Newspack\Corrections' ) && defined( 'NEWSPACK_CORRECTIONS_ENABLED' ) && NEWSPACK_CORRECTIONS_ENABLED ) { + require_once NEWSPACK_ABSPATH . 'src/blocks/correction-box/class-correction-box-block.php'; + } + \add_action( 'enqueue_block_editor_assets', [ __CLASS__, 'enqueue_block_editor_assets' ] ); } @@ -47,6 +52,7 @@ public static function enqueue_block_editor_assets() { 'reader_activation_url' => Reader_Activation::get_setting( 'terms_url' ), 'has_recaptcha' => Recaptcha::can_use_captcha(), 'recaptcha_url' => admin_url( 'admin.php?page=newspack-connections-wizard' ), + 'corrections_enabled' => class_exists( 'Newspack\Corrections' ) && defined( 'NEWSPACK_CORRECTIONS_ENABLED' ) && NEWSPACK_CORRECTIONS_ENABLED, ] ); \wp_enqueue_style( diff --git a/src/blocks/correction-box/block.json b/src/blocks/correction-box/block.json new file mode 100644 index 0000000000..395347ba73 --- /dev/null +++ b/src/blocks/correction-box/block.json @@ -0,0 +1,43 @@ +{ + "name": "newspack/correction-box", + "category": "newspack", + "attributes": {}, + "supports": { + "html": false, + "__experimentalBorder": { + "color": true, + "radius": true, + "style": true, + "width": true + }, + "color": { + "link": true, + "__experimentalDefaultControls": { + "background": true, + "text": true + } + }, + "spacing": { + "margin": true, + "padding": true + }, + "shadow": true, + "typography": { + "fontSize": true, + "lineHeight": true, + "textAlign": true, + "__experimentalFontFamily": true, + "__experimentalTextDecoration": true, + "__experimentalFontStyle": true, + "__experimentalFontWeight": true, + "__experimentalLetterSpacing": true, + "__experimentalTextTransform": true, + "__experimentalWritingMode": true, + "__experimentalDefaultControls": { + "fontSize": true + } + } + }, + "usesContext": [ "postId" ], + "textdomain": "newspack-plugin" +} diff --git a/src/blocks/correction-box/class-correction-box-block.php b/src/blocks/correction-box/class-correction-box-block.php new file mode 100644 index 0000000000..034a1e26b2 --- /dev/null +++ b/src/blocks/correction-box/class-correction-box-block.php @@ -0,0 +1,100 @@ + [ __CLASS__, 'render_block' ], + 'uses_context' => [ 'postId' ], + ] + ); + } + + /** + * Block render callback. + * + * @param array $attributes The block attributes. + * @param string $content The block content. + * @param object $block The block. + * + * @return string The block HTML. + */ + public static function render_block( array $attributes, string $content, $block ) { + $post_id = $block->context['postId'] ?? null; + + if ( empty( $post_id ) ) { + return ''; + } + + // Fetch corrections. + $corrections = Corrections::get_corrections( $post_id ); + + if ( empty( $corrections ) ) { + return ''; + } + + $block_wrapper_attributes = get_block_wrapper_attributes( + [ + 'class' => 'correction-box', + ] + ); + $corrections_archive_url = get_post_type_archive_link( Corrections::POST_TYPE ); + + ob_start(); + ?> +
> + post_content; + $correction_date = \get_the_date( get_option( 'date_format' ), $correction->ID ); + $correction_time = \get_the_time( get_option( 'time_format' ), $correction->ID ); + $timezone = \wp_timezone()->getName(); + $correction_heading = sprintf( + '%s, %s %s %s:', + Corrections::get_correction_type( $correction->ID ), + $correction_date, + $correction_time, + $timezone + ); + ?> +

+ + + + + + +

+ +
+ select( 'core/editor' ).getCurrentPostType(), [] ); + + /** + * Placeholder when no Corrections are available. + * + * @return {JSX.Element} The Empty Placeholder JSX. + */ + function EmptyPlaceholder() { + return ( + <> +

+ { __( + 'This is the Corrections block, it will display all the corrections and clarifications.', + 'newspack-plugin' + ) } +

+

+ { __( + 'If there are no corrections or clarifications, this block will not be displayed.', + 'newspack-plugin' + ) } +

+ + ); + } + + /** + * Toggle Refresh state. + */ + const toggleRefresh = () => { + setIsRefreshing( ! isRefreshing ); + }; + + return 'wp_template' === postType ? ( + + ) : ( + <> + + + + + + + + ); +} diff --git a/src/blocks/correction-box/index.js b/src/blocks/correction-box/index.js new file mode 100644 index 0000000000..413474b775 --- /dev/null +++ b/src/blocks/correction-box/index.js @@ -0,0 +1,39 @@ +/** + * WordPress dependencies + */ +import { Path, SVG } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ +import './style.scss'; +import metadata from './block.json'; +import Edit from './edit'; + +export const title = __( 'Corrections', 'newspack-plugin' ); + +export const icon = ( + + + +); + +const { name } = metadata; + +export { metadata, name }; + +export const settings = { + title, + icon: { + src: icon, + foreground: '#406ebc', + }, + keywords: [ __( 'clarifications', 'newspack-plugin' ), __( 'updates', 'newspack-plugin' ) ], + description: __( + 'Display all corrections and clarifications made to a post.', + 'newspack-plugin' + ), + usesContext: [ 'postId' ], + edit: Edit +}; diff --git a/src/blocks/correction-box/style.scss b/src/blocks/correction-box/style.scss new file mode 100644 index 0000000000..b4aa4ccc2f --- /dev/null +++ b/src/blocks/correction-box/style.scss @@ -0,0 +1,10 @@ +.wp-block-newspack-correction-box { + + p { + margin: 0; + } + + p.correction + p.correction { + margin-block-start: var(--wp--preset--spacing--30); + } +} diff --git a/src/blocks/index.js b/src/blocks/index.js index be0db195c3..e029bfebff 100644 --- a/src/blocks/index.js +++ b/src/blocks/index.js @@ -9,15 +9,17 @@ import { registerBlockType } from '@wordpress/blocks'; * Internal dependencies */ import * as readerRegistration from './reader-registration'; +import * as correctionBox from './correction-box'; /** * Block Scripts */ import './core-image'; -export const blocks = [ readerRegistration ]; +export const blocks = [ readerRegistration, correctionBox ]; const readerActivationBlocks = [ 'newspack/reader-registration' ]; +const correctionBlocks = [ 'newspack/correction-box' ]; /** * Function to register an individual block. @@ -36,6 +38,11 @@ const registerBlock = block => { return; } + /** Do not register correction blocks if it's disabled. */ + if ( correctionBlocks.includes( name ) && ! newspack_blocks.corrections_enabled ) { + return; + } + registerBlockType( { name, ...metadata }, settings ); }; diff --git a/webpack.config.js b/webpack.config.js index 3340fdd54c..2fce794dec 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -62,6 +62,13 @@ const entry = { 'reader-registration', 'view.js' ), + 'correction-box-block': path.join( + __dirname, + 'src', + 'blocks', + 'correction-box', + 'index.js' + ), 'my-account': path.join( __dirname, 'includes', From 034c13de7bec603ab258cab0ccaabb3f34013135 Mon Sep 17 00:00:00 2001 From: Takshil Kunadia Date: Fri, 28 Feb 2025 12:37:53 +0530 Subject: [PATCH 2/7] feat(corrections-blocks): add Correction Item block --- includes/class-blocks.php | 1 + src/blocks/correction-item/block.json | 44 +++++++++ .../class-correction-item-block.php | 96 +++++++++++++++++++ src/blocks/correction-item/index.js | 71 ++++++++++++++ src/blocks/correction-item/style.scss | 6 ++ src/blocks/index.js | 5 +- webpack.config.js | 7 ++ 7 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 src/blocks/correction-item/block.json create mode 100644 src/blocks/correction-item/class-correction-item-block.php create mode 100644 src/blocks/correction-item/index.js create mode 100644 src/blocks/correction-item/style.scss diff --git a/includes/class-blocks.php b/includes/class-blocks.php index 3c601794ee..94b1297270 100644 --- a/includes/class-blocks.php +++ b/includes/class-blocks.php @@ -21,6 +21,7 @@ public static function init() { if ( class_exists( 'Newspack\Corrections' ) && defined( 'NEWSPACK_CORRECTIONS_ENABLED' ) && NEWSPACK_CORRECTIONS_ENABLED ) { require_once NEWSPACK_ABSPATH . 'src/blocks/correction-box/class-correction-box-block.php'; + require_once NEWSPACK_ABSPATH . 'src/blocks/correction-item/class-correction-item-block.php'; } \add_action( 'enqueue_block_editor_assets', [ __CLASS__, 'enqueue_block_editor_assets' ] ); diff --git a/src/blocks/correction-item/block.json b/src/blocks/correction-item/block.json new file mode 100644 index 0000000000..abe9baecf5 --- /dev/null +++ b/src/blocks/correction-item/block.json @@ -0,0 +1,44 @@ +{ + "name": "newspack/correction-item", + "category": "newspack", + "attributes": {}, + "supports": { + "html": false, + "__experimentalBorder": { + "color": true, + "radius": true, + "style": true, + "width": true + }, + "color": { + "link": true, + "__experimentalDefaultControls": { + "background": true, + "text": true + } + }, + "spacing": { + "margin": true, + "padding": true + }, + "shadow": true, + "typography": { + "fontSize": true, + "lineHeight": true, + "textAlign": true, + "__experimentalFontFamily": true, + "__experimentalTextDecoration": true, + "__experimentalFontStyle": true, + "__experimentalFontWeight": true, + "__experimentalLetterSpacing": true, + "__experimentalTextTransform": true, + "__experimentalWritingMode": true, + "__experimentalDefaultControls": { + "fontSize": true + } + } + }, + "parent": [ "core/post-template" ], + "usesContext": [ "postId", "postType" ], + "textdomain": "newspack-plugin" +} diff --git a/src/blocks/correction-item/class-correction-item-block.php b/src/blocks/correction-item/class-correction-item-block.php new file mode 100644 index 0000000000..5f33a90285 --- /dev/null +++ b/src/blocks/correction-item/class-correction-item-block.php @@ -0,0 +1,96 @@ + [ __CLASS__, 'render_block' ], + ] + ); + } + + /** + * Block render callback. + * + * @param array $attributes The block attributes. + * @param string $content The block content. + * @param object $block The block. + * + * @return string The block HTML. + */ + public static function render_block( array $attributes, string $content, $block ) { + $correction_id = $block->context['postId'] ?? null; + + if ( empty( $correction_id ) || Corrections::POST_TYPE !== $block->context['postType'] ) { + return ''; + } + + $correction = get_post( $correction_id ); + + if ( empty( $correction ) ) { + return ''; + } + + $block_wrapper_attributes = get_block_wrapper_attributes( + [ + 'class' => 'correction__item', + ] + ); + + ob_start(); + $correction_content = $correction->post_content; + $correction_date = \get_the_date( get_option( 'date_format' ), $correction->ID ); + $correction_time = \get_the_time( get_option( 'time_format' ), $correction->ID ); + $timezone = \wp_timezone()->getName(); + $correction_heading = sprintf( + '%s, %s %s %s:', + Corrections::get_correction_type( $correction->ID ), + $correction_date, + $correction_time, + $timezone + ); + $correction_related_post = get_post_meta( $correction->ID, Corrections::CORRECTION_POST_ID_META, true ); + $corrections_post_url = get_permalink( $correction_related_post ); + ?> +
> + + + + + + + + + +
+ + + +); + +const EditComponent = ( { context: { postType } } ) => { + if ( 'newspack_correction' !== postType ) { + return ( + + ); + } + + return ( + <> +
+ + { __( 'Correction Type, Date, and Time: ', 'newspack-plugin' ) } + + + { __( + 'This is where the content will appear, providing details about the update, whether correcting an error or offering additional context.', + 'newspack-plugin' + ) } + +
+ + { __( 'Post Title', 'newspack-plugin' ) } + + + ); +}; + +const { name } = metadata; + +export { metadata, name }; + +export const settings = { + title, + icon: { + src: icon, + foreground: '#406ebc', + }, + description: __( + 'Display an archive of all the corrections and clarifications.', + 'newspack-plugin' + ), + usesContext: [ 'postType' ], + edit: EditComponent, +}; diff --git a/src/blocks/correction-item/style.scss b/src/blocks/correction-item/style.scss new file mode 100644 index 0000000000..7c242df833 --- /dev/null +++ b/src/blocks/correction-item/style.scss @@ -0,0 +1,6 @@ +.correction { + + &__post-link { + display: block; + } +} diff --git a/src/blocks/index.js b/src/blocks/index.js index e029bfebff..fed4cc8776 100644 --- a/src/blocks/index.js +++ b/src/blocks/index.js @@ -10,16 +10,17 @@ import { registerBlockType } from '@wordpress/blocks'; */ import * as readerRegistration from './reader-registration'; import * as correctionBox from './correction-box'; +import * as correctionItem from './correction-item'; /** * Block Scripts */ import './core-image'; -export const blocks = [ readerRegistration, correctionBox ]; +export const blocks = [ readerRegistration, correctionBox, correctionItem ]; const readerActivationBlocks = [ 'newspack/reader-registration' ]; -const correctionBlocks = [ 'newspack/correction-box' ]; +const correctionBlocks = [ 'newspack/correction-box', 'newspack/correction-item' ]; /** * Function to register an individual block. diff --git a/webpack.config.js b/webpack.config.js index 2fce794dec..ca0126002d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -69,6 +69,13 @@ const entry = { 'correction-box', 'index.js' ), + 'correction-item-block': path.join( + __dirname, + 'src', + 'blocks', + 'correction-item', + 'index.js' + ), 'my-account': path.join( __dirname, 'includes', From df3816bbfe1aade814b7d2ee01093bd22466abe3 Mon Sep 17 00:00:00 2001 From: Takshil Kunadia Date: Fri, 28 Feb 2025 12:40:48 +0530 Subject: [PATCH 3/7] feat(corrections-blocks): register Corrections Loop block pattern --- includes/corrections/class-corrections.php | 44 ++++++++++++++++ .../corrections/corrections-loop.php | 50 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 includes/templates/block-patterns/corrections/corrections-loop.php diff --git a/includes/corrections/class-corrections.php b/includes/corrections/class-corrections.php index 06e5089390..dca06cbe5c 100644 --- a/includes/corrections/class-corrections.php +++ b/includes/corrections/class-corrections.php @@ -70,6 +70,7 @@ public static function init() { add_action( 'wp_enqueue_scripts', [ __CLASS__, 'wp_enqueue_scripts' ] ); add_action( 'admin_enqueue_scripts', [ __CLASS__, 'wp_enqueue_scripts' ] ); add_action( 'rest_api_init', [ __CLASS__, 'register_rest_routes' ] ); + add_action( 'admin_init', [ __CLASS__, 'register_corrections_block_patterns' ] ); } /** @@ -545,5 +546,48 @@ public static function corrections_customize_register( $wp_customize ) { ) ); } + + /** + * Registers the block template. + */ + public static function register_corrections_block_patterns() { + if ( ! class_exists( 'WP_Block_Patterns_Registry' ) || ! wp_is_block_theme() ) { + return; + } + + $category = 'newspack-corrections'; + + \register_block_pattern_category( + $category, + [ + 'label' => __( 'Newspack Corrections', 'newspack-plugin' ), + ] + ); + + \register_block_pattern( + 'newspack/corrections-loop', + [ + 'categories' => [ $category ], + 'title' => __( 'Corrections Loop', 'newspack-plugin' ), + 'description' => __( 'A block pattern for displaying an archive of corrections.', 'newspack-plugin' ), + 'content' => self::get_corrections_pattern_content( 'corrections-loop' ), + 'keywords' => [ __( 'corrections', 'newspack-plugin' ), __( 'archive', 'newspack-plugin' ), __( 'loop', 'newspack-plugin' ) ], + ] + ); + } + + /** + * Retrieves the block template content. + * + * @param string $pattern The pattern name. + * + * @return string The template content. + */ + private static function get_corrections_pattern_content( $pattern ) { + ob_start(); + include_once __DIR__ . "/../templates/block-patterns/corrections/{$pattern}.php"; + $content = ob_get_clean(); + return $content; + } } Corrections::init(); diff --git a/includes/templates/block-patterns/corrections/corrections-loop.php b/includes/templates/block-patterns/corrections/corrections-loop.php new file mode 100644 index 0000000000..d874b3787b --- /dev/null +++ b/includes/templates/block-patterns/corrections/corrections-loop.php @@ -0,0 +1,50 @@ + + + +
+ +
+ + +
+ +

Corrections & Clarifications

+ + + +

We are committed to truthful, transparent, and accurate reporting. When we make a mistake, we correct it promptly and note the change clearly. Clarifications, when needed, provide additional context.

+ +
+ + + + + + + +
+ +
+ + + + + + + + + +
+ + +
+ +
+ From 45ff1645016593014f699f9d9c9783d2a6c8cdf9 Mon Sep 17 00:00:00 2001 From: Takshil Kunadia Date: Fri, 28 Feb 2025 12:47:00 +0530 Subject: [PATCH 4/7] feat(corrections-blocks): add Corrections archive block template --- includes/corrections/class-corrections.php | 33 +++++++++ .../corrections/corrections-archive.php | 70 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 includes/templates/corrections/corrections-archive.php diff --git a/includes/corrections/class-corrections.php b/includes/corrections/class-corrections.php index dca06cbe5c..f52cfd0123 100644 --- a/includes/corrections/class-corrections.php +++ b/includes/corrections/class-corrections.php @@ -71,6 +71,7 @@ public static function init() { add_action( 'admin_enqueue_scripts', [ __CLASS__, 'wp_enqueue_scripts' ] ); add_action( 'rest_api_init', [ __CLASS__, 'register_rest_routes' ] ); add_action( 'admin_init', [ __CLASS__, 'register_corrections_block_patterns' ] ); + add_action( 'init', [ __CLASS__, 'register_corrections_template' ] ); } /** @@ -589,5 +590,37 @@ private static function get_corrections_pattern_content( $pattern ) { $content = ob_get_clean(); return $content; } + + /** + * Registers the block template. + */ + public static function register_corrections_template() { + if ( ! class_exists( 'WP_Block_Templates_Registry' ) || ! wp_is_block_theme() ) { + return; + } + + \register_block_template( + 'newspack//corrections-archive', + [ + 'title' => __( 'Corrections Archive', 'newspack-plugin' ), + 'description' => __( 'A block template for displaying an archive of corrections.', 'newspack-plugin' ), + 'content' => self::get_corrections_template_content( 'corrections-archive' ), + ] + ); + } + + /** + * Retrieves the block template content. + * + * @param string $template The template name. + * + * @return string The template content. + */ + private static function get_corrections_template_content( $template ) { + ob_start(); + include_once __DIR__ . "/../templates/corrections/{$template}.php"; + $content = ob_get_clean(); + return $content; + } } Corrections::init(); diff --git a/includes/templates/corrections/corrections-archive.php b/includes/templates/corrections/corrections-archive.php new file mode 100644 index 0000000000..c2a94ec51e --- /dev/null +++ b/includes/templates/corrections/corrections-archive.php @@ -0,0 +1,70 @@ + + + +

Replace this with your Header

+ + + +
+ + +
+ +

Corrections & Clarifications

+ + + +

We are committed to truthful, transparent, and accurate reporting. When we make a mistake, we correct it promptly and note the change clearly. Clarifications, when needed, provide additional context.

+ +
+ + + +
+ +
+ + + +
+ + + +
+ + + +
+ +
+ + + +
+ +
+ + + + + + + + + +
+ + +
+ + + +

Replace this with your Footer

+ From 1849888bc4b4793425e07411d6dc0876247a77ce Mon Sep 17 00:00:00 2001 From: Takshil Kunadia Date: Mon, 3 Mar 2025 16:08:17 +0530 Subject: [PATCH 5/7] refactor(correction-blocks): remove timezone from correction heading --- src/blocks/correction-box/class-correction-box-block.php | 6 ++---- src/blocks/correction-item/class-correction-item-block.php | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/blocks/correction-box/class-correction-box-block.php b/src/blocks/correction-box/class-correction-box-block.php index 034a1e26b2..237c7ed8fa 100644 --- a/src/blocks/correction-box/class-correction-box-block.php +++ b/src/blocks/correction-box/class-correction-box-block.php @@ -73,13 +73,11 @@ public static function render_block( array $attributes, string $content, $block $correction_content = $correction->post_content; $correction_date = \get_the_date( get_option( 'date_format' ), $correction->ID ); $correction_time = \get_the_time( get_option( 'time_format' ), $correction->ID ); - $timezone = \wp_timezone()->getName(); $correction_heading = sprintf( - '%s, %s %s %s:', + '%s, %s %s:', Corrections::get_correction_type( $correction->ID ), $correction_date, - $correction_time, - $timezone + $correction_time ); ?>

diff --git a/src/blocks/correction-item/class-correction-item-block.php b/src/blocks/correction-item/class-correction-item-block.php index 5f33a90285..4610b7a2ea 100644 --- a/src/blocks/correction-item/class-correction-item-block.php +++ b/src/blocks/correction-item/class-correction-item-block.php @@ -66,13 +66,11 @@ public static function render_block( array $attributes, string $content, $block $correction_content = $correction->post_content; $correction_date = \get_the_date( get_option( 'date_format' ), $correction->ID ); $correction_time = \get_the_time( get_option( 'time_format' ), $correction->ID ); - $timezone = \wp_timezone()->getName(); $correction_heading = sprintf( - '%s, %s %s %s:', + '%s, %s %s:', Corrections::get_correction_type( $correction->ID ), $correction_date, - $correction_time, - $timezone + $correction_time ); $correction_related_post = get_post_meta( $correction->ID, Corrections::CORRECTION_POST_ID_META, true ); $corrections_post_url = get_permalink( $correction_related_post ); From b5bec74687ce56054e6518cc83892b5b48c6e684 Mon Sep 17 00:00:00 2001 From: Takshil Kunadia Date: Mon, 3 Mar 2025 16:08:33 +0530 Subject: [PATCH 6/7] feat(corrections-blocks): add translation support for Corrections & Clarifications text --- .../block-patterns/corrections/corrections-loop.php | 4 ++-- includes/templates/corrections/corrections-archive.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/templates/block-patterns/corrections/corrections-loop.php b/includes/templates/block-patterns/corrections/corrections-loop.php index d874b3787b..72356b2243 100644 --- a/includes/templates/block-patterns/corrections/corrections-loop.php +++ b/includes/templates/block-patterns/corrections/corrections-loop.php @@ -15,11 +15,11 @@

-

Corrections & Clarifications

+

-

We are committed to truthful, transparent, and accurate reporting. When we make a mistake, we correct it promptly and note the change clearly. Clarifications, when needed, provide additional context.

+

diff --git a/includes/templates/corrections/corrections-archive.php b/includes/templates/corrections/corrections-archive.php index c2a94ec51e..b59c4615d3 100644 --- a/includes/templates/corrections/corrections-archive.php +++ b/includes/templates/corrections/corrections-archive.php @@ -8,7 +8,7 @@ ?> -

Replace this with your Header

+

@@ -17,11 +17,11 @@
-

Corrections & Clarifications

+

-

We are committed to truthful, transparent, and accurate reporting. When we make a mistake, we correct it promptly and note the change clearly. Clarifications, when needed, provide additional context.

+

@@ -66,5 +66,5 @@ -

Replace this with your Footer

+

From 31c3a1db12c1232561b6aef7c9793f27b5cb57b4 Mon Sep 17 00:00:00 2001 From: Takshil Kunadia Date: Mon, 3 Mar 2025 17:37:19 +0530 Subject: [PATCH 7/7] refactor(corrections-blocks): check for block theme before registering blocks --- includes/class-blocks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-blocks.php b/includes/class-blocks.php index 94b1297270..1236c58e0f 100644 --- a/includes/class-blocks.php +++ b/includes/class-blocks.php @@ -19,7 +19,7 @@ final class Blocks { public static function init() { require_once NEWSPACK_ABSPATH . 'src/blocks/reader-registration/index.php'; - if ( class_exists( 'Newspack\Corrections' ) && defined( 'NEWSPACK_CORRECTIONS_ENABLED' ) && NEWSPACK_CORRECTIONS_ENABLED ) { + if ( wp_is_block_theme() && class_exists( 'Newspack\Corrections' ) && defined( 'NEWSPACK_CORRECTIONS_ENABLED' ) && NEWSPACK_CORRECTIONS_ENABLED ) { require_once NEWSPACK_ABSPATH . 'src/blocks/correction-box/class-correction-box-block.php'; require_once NEWSPACK_ABSPATH . 'src/blocks/correction-item/class-correction-item-block.php'; } @@ -53,7 +53,7 @@ public static function enqueue_block_editor_assets() { 'reader_activation_url' => Reader_Activation::get_setting( 'terms_url' ), 'has_recaptcha' => Recaptcha::can_use_captcha(), 'recaptcha_url' => admin_url( 'admin.php?page=newspack-connections-wizard' ), - 'corrections_enabled' => class_exists( 'Newspack\Corrections' ) && defined( 'NEWSPACK_CORRECTIONS_ENABLED' ) && NEWSPACK_CORRECTIONS_ENABLED, + 'corrections_enabled' => wp_is_block_theme() && class_exists( 'Newspack\Corrections' ) && defined( 'NEWSPACK_CORRECTIONS_ENABLED' ) && NEWSPACK_CORRECTIONS_ENABLED, ] ); \wp_enqueue_style(