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

core/block-editor getSettings() does not return custom settings added from filter #41338

Closed
coreyworrell opened this issue May 25, 2022 · 4 comments
Labels
[Package] Block editor /packages/block-editor

Comments

@coreyworrell
Copy link
Contributor

Description

According to https://make.wordpress.org/core/2022/05/03/block-editor-miscellaneous-dev-notes-for-wordpress-6-0/#removed-6-2, wp.data.select( 'core/editor' ).+ name has been deprecated in favor of wp.data.select( 'core/block-editor' ). + name.

When using the filter block_editor_settings_all, additional settings aren't always included in core/block-editor, for example when editing a page. They are included when editing widgets though.

Step-by-step reproduction instructions

add_filter('block_editor_settings_all', function (array $settings): array {
  $settings['customAttribute'] = ['one', 'two', 'three'];
  return $settings;
});

Then on post.php

wp.data.select('core/editor').getEditorSettings().customAttribute
// Array(3) [ "one", "two", "three" ]

wp.data.select('core/block-editor').getSettings().customAttribute
// undefined

And those values are swapped on the widgets page.

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.0

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@adamwoodnz adamwoodnz added Needs Testing Needs further testing to be confirmed. [Package] Block editor /packages/block-editor labels May 30, 2022
@t-hamano
Copy link
Contributor

t-hamano commented Jul 10, 2022

Hi @coreyworrell,

I took a look at the PR(#37854) that was the source of the post.
From my research, the selectors deprecated in the editor package are limited to the following:

  • getAutosaveAttribute
  • getEditorSelectionStart
  • getEditorSelectionEnd
  • getStateBeforeOptimisticTransaction
  • inSomeHistory
  • getBlockEditorSelector

As for getEditorSettings, it does not appear to be subject to deprecation.

/**
* Returns the post editor settings.
*
* @param {Object} state Editor state.
*
* @return {Object} The editor settings object.
*/
export function getEditorSettings( state ) {
return state.editorSettings;
}

@youknowriad
As for getEditorSettings, am I correct that it is not deprecated in 6.2?

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 26, 2022
@mrfoxtalbot
Copy link

mrfoxtalbot commented Sep 19, 2022

Thank you for reporting this, @coreyworrell and thank you for taking a look, @t-hamano. This issue has not seen any activity for a while. Could you please confirm if this is still reproducible? Thank you!

@github-actions github-actions bot removed the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Sep 20, 2022
@t-hamano
Copy link
Contributor

Thank you for the reminder, @mrfoxtalbot.

@coreyworrell
As I commented here, I don't think all of 'core/editor' has been completely deprecated.
At the least, you should still be able to use wp.data.select('core/editor').getEditorSettings().
I am closing this issue, but feel free to reopen it if you have any problems.

@t-hamano t-hamano removed the Needs Testing Needs further testing to be confirmed. label Sep 20, 2022
@mrfoxtalbot
Copy link

Thank you @t-hamano!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block editor /packages/block-editor
4 participants