Remove unnecessary use of mailpoet_data
MAILPOET-6431
This commit is contained in:
committed by
Oluwaseun Olorunsola
parent
9ad79e75b5
commit
e5498b6baf
@ -62,3 +62,14 @@ addFilter(
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||||
(RichTextWithButton) => EmailSidebarExtension.bind(null, RichTextWithButton),
|
(RichTextWithButton) => EmailSidebarExtension.bind(null, RichTextWithButton),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// use mailpoet data subject if available
|
||||||
|
addFilter(
|
||||||
|
'mailpoet_email_editor_preferred_template_title',
|
||||||
|
'mailpoet',
|
||||||
|
(...args) => {
|
||||||
|
const [, post] = args;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||||
|
return post?.mailpoet_data?.subject || ''; // use MailPoet subject as title
|
||||||
|
},
|
||||||
|
);
|
||||||
|
@ -5,6 +5,7 @@ import { useMemo } from '@wordpress/element';
|
|||||||
import { parse } from '@wordpress/blocks';
|
import { parse } from '@wordpress/blocks';
|
||||||
import { BlockInstance } from '@wordpress/blocks/index';
|
import { BlockInstance } from '@wordpress/blocks/index';
|
||||||
import { useSelect } from '@wordpress/data';
|
import { useSelect } from '@wordpress/data';
|
||||||
|
import { applyFilters } from '@wordpress/hooks';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
@ -163,6 +164,11 @@ export function usePreviewTemplates(
|
|||||||
|
|
||||||
const allEmailPosts = useMemo( () => {
|
const allEmailPosts = useMemo( () => {
|
||||||
return emailPosts?.map( ( post: EmailEditorPostType ) => {
|
return emailPosts?.map( ( post: EmailEditorPostType ) => {
|
||||||
|
const preferredTitle = applyFilters(
|
||||||
|
'mailpoet_email_editor_preferred_template_title',
|
||||||
|
'',
|
||||||
|
post
|
||||||
|
);
|
||||||
const { postTemplateContent } = generateTemplateContent(
|
const { postTemplateContent } = generateTemplateContent(
|
||||||
post,
|
post,
|
||||||
allTemplates
|
allTemplates
|
||||||
@ -180,9 +186,8 @@ export function usePreviewTemplates(
|
|||||||
const template = {
|
const template = {
|
||||||
...post,
|
...post,
|
||||||
title: {
|
title: {
|
||||||
raw: post?.mailpoet_data?.subject || post.title.raw,
|
raw: post.title.raw,
|
||||||
rendered:
|
rendered: preferredTitle || post.title.rendered,
|
||||||
post?.mailpoet_data?.subject || post.title.rendered, // use MailPoet subject as title
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
|
@ -96,13 +96,8 @@ export const isEmpty = createRegistrySelector( ( select ) => (): boolean => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { content, mailpoet_data: mailpoetData, title } = post;
|
const { content, title } = post;
|
||||||
return (
|
return ! content.raw && ! title.raw;
|
||||||
! content.raw &&
|
|
||||||
! mailpoetData.subject &&
|
|
||||||
! mailpoetData.preheader &&
|
|
||||||
! title.raw
|
|
||||||
);
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
export const hasEmptyContent = createRegistrySelector(
|
export const hasEmptyContent = createRegistrySelector(
|
||||||
|
@ -261,7 +261,6 @@ export type MailPoetEmailPostContentExtended = {
|
|||||||
|
|
||||||
export type EmailEditorPostType = Omit< Post, 'type' > & {
|
export type EmailEditorPostType = Omit< Post, 'type' > & {
|
||||||
type: string;
|
type: string;
|
||||||
mailpoet_data?: MailPoetEmailPostContentExtended;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type EmailContentValidationAction = {
|
export type EmailContentValidationAction = {
|
||||||
|
@ -75,5 +75,3 @@ We may add, update and delete any of them.
|
|||||||
| `mailpoet_email_editor_send_preview_email` | `Array` $postData | `boolean` Result of processing. Was email sent successfully? | Allows override of the send preview mail function. Folks may choose to use custom implementation |
|
| `mailpoet_email_editor_send_preview_email` | `Array` $postData | `boolean` Result of processing. Was email sent successfully? | Allows override of the send preview mail function. Folks may choose to use custom implementation |
|
||||||
| `mailpoet_email_editor_post_sent_status_args` | `Array` `sent` post status args | `Array` register_post_status args | Allows update of the argument for the sent post status |
|
| `mailpoet_email_editor_post_sent_status_args` | `Array` `sent` post status args | `Array` register_post_status args | Allows update of the argument for the sent post status |
|
||||||
|
|
||||||
## TODO
|
|
||||||
- We use `mailpoet_data` in some section of the codebase. This will be updated.
|
|
||||||
|
Reference in New Issue
Block a user