-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Lodash: Remove _.get()
for post type usages
#48121
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { get } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
@@ -105,7 +100,6 @@ function PostFeaturedImage( { | |
const mediaUpload = useSelect( ( select ) => { | ||
return select( blockEditorStore ).getSettings().mediaUpload; | ||
}, [] ); | ||
const postLabel = get( postType, [ 'labels' ], {} ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of defaulting to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, done as part of bfdd842 |
||
const { mediaWidth, mediaHeight, mediaSourceUrl } = getMediaDetails( | ||
media, | ||
currentPostId | ||
|
@@ -159,7 +153,7 @@ function PostFeaturedImage( { | |
<MediaUploadCheck fallback={ instructions }> | ||
<MediaUpload | ||
title={ | ||
postLabel.featured_image || | ||
postType?.labels?.featured_image || | ||
DEFAULT_FEATURE_IMAGE_LABEL | ||
} | ||
onSelect={ onUpdateImage } | ||
|
@@ -201,7 +195,8 @@ function PostFeaturedImage( { | |
{ isLoading && <Spinner /> } | ||
{ ! featuredImageId && | ||
! isLoading && | ||
( postLabel.set_featured_image || | ||
( postType?.labels | ||
?.set_featured_image || | ||
DEFAULT_SET_FEATURE_IMAGE_LABEL ) } | ||
</Button> | ||
<DropZone onFilesDrop={ onDropFiles } /> | ||
|
@@ -215,7 +210,7 @@ function PostFeaturedImage( { | |
{ media && ( | ||
<MediaUpload | ||
title={ | ||
postLabel.featured_image || | ||
postType?.labels?.featured_image || | ||
DEFAULT_FEATURE_IMAGE_LABEL | ||
} | ||
onSelect={ onUpdateImage } | ||
|
@@ -237,7 +232,7 @@ function PostFeaturedImage( { | |
variant="link" | ||
isDestructive | ||
> | ||
{ postLabel.remove_featured_image || | ||
{ postType?.labels?.remove_featured_image || | ||
DEFAULT_REMOVE_FEATURE_IMAGE_LABEL } | ||
</Button> | ||
</MediaUploadCheck> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we could just return
isHiearchical
(andparentPageLabel
, too) from theuseSelect
callback few lines above. It already computes it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, reused in bfdd842.