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

Editor plugins: do not load post editor plugins in site editor #37819

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/update-site-editor-plugins
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: compat

Editor functionality: ensure that features added by Jetpack to the block editor are compatible with site editor changes introduced in WordPres 6.6.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import { JetpackEditorPanelLogo } from '@automattic/jetpack-shared-extension-utils';
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
import { PanelBody, PanelRow, BaseControl } from '@wordpress/components';
import { select } from '@wordpress/data';
import { PluginPrePublishPanel, PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { store as editorStore } from '@wordpress/editor';
import { __ } from '@wordpress/i18n';
import debugFactory from 'debug';
import React from 'react';
Expand Down Expand Up @@ -96,6 +98,13 @@ export default function AiAssistantPluginSidebar() {
tracks.recordEvent( 'jetpack_ai_panel_open', { placement } );
};

const postType = select( editorStore ).getCurrentPostType();

// If postType is still not available, simply return and wait for the next call.
if ( postType === null ) {
return;
}

return (
<>
<JetpackPluginSidebar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ export const settings = {
initialOpen: false,
};

const isPostPublished = useSelect(
select => select( editorStore ).isCurrentPostPublished(),
[]
);
const { isPostPublished, postType } = useSelect( select => {
return {
isPostPublished: select( editorStore ).isCurrentPostPublished(),
postType: select( editorStore ).getCurrentPostType(),
};
}, [] );

// If postType is still not available, simply return and wait for the next call.
if ( postType === null ) {
return;
}

function QRPostPanelBodyContent() {
return (
Expand Down
10 changes: 10 additions & 0 deletions projects/plugins/jetpack/extensions/plugins/seo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
getRequiredPlan,
} from '@automattic/jetpack-shared-extension-utils';
import { PanelBody, PanelRow } from '@wordpress/components';
import { select } from '@wordpress/data';
import { PluginPrePublishPanel } from '@wordpress/edit-post';
import { store as editorStore } from '@wordpress/editor';
import { Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import JetpackPluginSidebar from '../../shared/jetpack-plugin-sidebar';
Expand All @@ -32,6 +34,14 @@ const Seo = () => {
title: __( 'SEO', 'jetpack' ),
};

// Those tools are only useful in the post editor.
const postType = select( editorStore ).getCurrentPostType();

// If postType is still not available, simply return and wait for the next call.
if ( postType === null ) {
return;
}

if ( canShowUpsell && requiredPlan !== false ) {
return (
<Fragment>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { SocialPreviewsModal, SocialPreviewsPanel } from '@automattic/jetpack-publicize-components';
import { JetpackEditorPanelLogo } from '@automattic/jetpack-shared-extension-utils';
import { PanelBody } from '@wordpress/components';
import { select } from '@wordpress/data';
import { PluginPrePublishPanel } from '@wordpress/edit-post';
import { store as editorStore } from '@wordpress/editor';
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import JetpackPluginSidebar from '../../shared/jetpack-plugin-sidebar';
Expand All @@ -15,6 +17,13 @@ export const settings = {
export const SocialPreviews = function SocialPreviews() {
const [ isOpened, setIsOpened ] = useState( false );

const postType = select( editorStore ).getCurrentPostType();

// If postType is still not available, simply return and wait for the next call.
if ( postType === null ) {
return;
}

return (
<>
{ isOpened && <SocialPreviewsModal onClose={ () => setIsOpened( false ) } /> }
Expand Down
Loading