Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-48: Change Newsletter Single Post to use inner blocks #50

Merged
merged 13 commits into from
Dec 1, 2023

Conversation

mogmarsh
Copy link
Collaborator

@mogmarsh mogmarsh commented Nov 21, 2023


name: Change Newsletter Single Post to use inner blocks
about: Convert the display logic of Newsletter Single Post block to utilize inner blocks and context.
title: ''
labels: ''
assignees: ''

This PR switches the Newsletter Single Post block to use InnerBlocks and converts the Post Title and Post Featured Image to new blocks. We need to use custom blocks to allow for overrides. There will be more custom blocks in a future PR.


Issue Number

#48

Description

Currently, the logic for displaying a post is all inside the Newsletter Single Post block and powered by the show____ and order attributes. We should change this to use inner blocks and context. Hopefully the core inner blocks will work, but if not, we should create the necessary inner blocks. Display should still use the same markup, as that has been deemed "email safe".

Use Case

Using inner blocks will give editors more control over their templates and allow developers to create their own blocks to add to the layout to display an eyebrow, for instance.

Additional Context

This change will probably also allow us to use it in conjunction with the core Query Loop block or WP Curate query block, which will allow some sections of a newsletter to be more automated. See alleyinteractive/wp-newsletter-builder#26.

Copy link
Member

@attackant attackant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐙

if ( empty( $wp_newsletter_builder_block_post ) || ! $wp_newsletter_builder_block_post ) {
return;
}
$wp_newsletter_builder_post_title = ! empty( $attributes['overrideTitle'] ) ? $attributes['overrideTitle'] : $wp_newsletter_builder_block_post->post_title;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be:
$wp_newsletter_builder_post_title = $attributes['overrideTitle'] ?? $wp_newsletter_builder_block_post->post_title;

if ( ! empty( $block['attrs']['overrideUrl'] ) ) {
add_filter(
'post_link',
function() use ( $block ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool I didn't know about use

@mogmarsh mogmarsh merged commit 64b1e04 into develop Dec 1, 2023
7 checks passed
@mogmarsh mogmarsh deleted the feature/issue-48/change-single-post-inner-blocks branch December 1, 2023 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants