fix: guard CHRNX editorial state
This commit is contained in:
8 files changed
+285
-19
No files matched your search
@@ -54,15 +54,30 @@
|
||||
}
|
||||
|
||||
const editor = wp.data.select( 'core/editor' );
|
||||
if ( ! editor || editor.getCurrentPostType() !== 'post' ) {
|
||||
if (
|
||||
! editor ||
|
||||
typeof editor.getCurrentPostType !== 'function' ||
|
||||
typeof editor.getEditedPostAttribute !== 'function' ||
|
||||
editor.getCurrentPostType() !== 'post'
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function PodcastPanel() {
|
||||
const editorState = wp.data.useSelect( function ( select ) {
|
||||
if ( typeof select !== 'function' ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentEditor = select( 'core/editor' );
|
||||
const core = select( 'core' );
|
||||
if ( ! currentEditor || ! core || typeof core.getEntityRecord !== 'function' ) {
|
||||
if (
|
||||
! currentEditor ||
|
||||
typeof currentEditor.getCurrentPostType !== 'function' ||
|
||||
typeof currentEditor.getEditedPostAttribute !== 'function' ||
|
||||
! core ||
|
||||
typeof core.getEntityRecord !== 'function'
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,12 @@
|
||||
}
|
||||
|
||||
const editor = wp.data.select( 'core/editor' );
|
||||
if ( ! editor || editor.getCurrentPostType() !== 'post' ) {
|
||||
if (
|
||||
! editor ||
|
||||
typeof editor.getCurrentPostType !== 'function' ||
|
||||
typeof editor.getEditedPostAttribute !== 'function' ||
|
||||
editor.getCurrentPostType() !== 'post'
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -71,9 +76,19 @@
|
||||
|
||||
function EditorialTaxonomyPanels() {
|
||||
const editorState = wp.data.useSelect( function ( select ) {
|
||||
if ( typeof select !== 'function' ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentEditor = select( 'core/editor' );
|
||||
const core = select( 'core' );
|
||||
if ( ! currentEditor || ! core || typeof core.getEntityRecords !== 'function' ) {
|
||||
if (
|
||||
! currentEditor ||
|
||||
typeof currentEditor.getCurrentPostType !== 'function' ||
|
||||
typeof currentEditor.getEditedPostAttribute !== 'function' ||
|
||||
! core ||
|
||||
typeof core.getEntityRecords !== 'function'
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user