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

External Media: support editor changes in WordPress 6.5 #36188

Merged
merged 10 commits into from
May 6, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

External Media: support editor changes in WordPress 6.5.
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,23 @@ const isMediaSourceConnected = async ( source: MediaSource ) =>
*
* @returns {boolean} True if the inserter is opened false otherwise.
*/
const isInserterOpened = (): boolean =>
select( 'core/edit-post' )?.isInserterOpened() ||
select( 'core/edit-site' )?.isInserterOpened() ||
select( 'core/edit-widgets' )?.isInserterOpened?.();
const isInserterOpened = (): boolean => {
// Prior to WP 6.5, the isInserterOpened selector was available in core/edit-post.
// In WP 6.5, it was moved to core/editor. This check is to support both versions of WordPress.
// @to-do: remove exception when Jetpack requires WordPress 6.5.
const selectIsInserterOpened =
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
( select( 'core/editor' ) as any )?.isInserterOpened ??
select( 'core/edit-post' )?.isInserterOpened;

const editorIsInserterOpened = selectIsInserterOpened?.();

return (
editorIsInserterOpened ||
select( 'core/edit-site' )?.isInserterOpened() ||
select( 'core/edit-widgets' )?.isInserterOpened()
);
};

const registerInInserter = ( mediaCategoryProvider: () => object ) =>
// Remove as soon @types/wordpress__block-editor is up to date
Expand Down
Loading