Skip to content
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
/packages/block-library/src/page-list @tellthemachines
/packages/block-library/src/comment-template @michalczaplinski
/packages/block-library/src/comments-query-loop @michalczaplinski
/packages/block-library/src/avatar @c4rl0sbr4v0

# Duotone
/lib/block-supports/duotone.php @ajlende
Expand Down
31 changes: 31 additions & 0 deletions lib/compat/wordpress-6.0/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,34 @@ function gutenberg_build_query_vars_from_query_block( $block, $page ) {
}
return $query;
}

/**
* Workaround for getting discussion settings as block editor settings
* so any user can access to them without needing to be an admin.
*
* @param array $settings Default editor settings.
*
* @return array Filtered editor settings.
*/
function gutenberg_extend_block_editor_settings_with_discussion_settings( $settings ) {

$settings['discussionSettings'] = array(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this setting experimental for now. We should look for a more general way to expose site options.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this setting experimental for now. We should look for a more general way to expose site options.

'commentOrder' => get_option( 'comment_order' ),
'commentsPerPage' => get_option( 'comments_per_page' ),
'defaultCommentsPage' => get_option( 'default_comments_page' ),
'pageComments' => get_option( 'page_comments' ),
'threadComments' => get_option( 'thread_comments' ),
'threadCommentsDepth' => get_option( 'thread_comments_depth' ),
'avatarURL' => get_avatar_url(
'',
array(
'size' => 96,
'force_default' => true,
'default' => get_option( 'avatar_default' ),
)
),
);

return $settings;
}
add_filter( 'block_editor_settings_all', 'gutenberg_extend_block_editor_settings_with_discussion_settings' );
33 changes: 0 additions & 33 deletions lib/experimental/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,39 +95,6 @@ function get_comments_pagination_arrow( $block, $pagination_type = 'next' ) {
}
}

if ( ! function_exists( 'extend_block_editor_settings_with_discussion_settings' ) ) {
/**
* Workaround for getting discussion settings as block editor settings
* so any user can access to them without needing to be an admin.
*
* @param array $settings Default editor settings.
*
* @return array Filtered editor settings.
*/
function extend_block_editor_settings_with_discussion_settings( $settings ) {

$settings['__experimentalDiscussionSettings'] = array(
'commentOrder' => get_option( 'comment_order' ),
'commentsPerPage' => get_option( 'comments_per_page' ),
'defaultCommentsPage' => get_option( 'default_comments_page' ),
'pageComments' => get_option( 'page_comments' ),
'threadComments' => get_option( 'thread_comments' ),
'threadCommentsDepth' => get_option( 'thread_comments_depth' ),
'avatarURL' => get_avatar_url(
'',
array(
'size' => 96,
'force_default' => true,
'default' => get_option( 'avatar_default' ),
)
),
);

return $settings;
}
}
add_filter( 'block_editor_settings_all', 'extend_block_editor_settings_with_discussion_settings' );

if ( ! function_exists( 'gutenberg_rest_comment_set_children_as_embeddable' ) ) {
/**
* Mark the `children` attr of comments as embeddable so they can be included in
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/avatar/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function getAvatarSizes( sizes ) {
function useDefaultAvatar() {
const { avatarURL: defaultAvatarUrl } = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
const { __experimentalDiscussionSettings } = getSettings();
return __experimentalDiscussionSettings;
const { discussionSettings } = getSettings();
return discussionSettings;
} );
return defaultAvatarUrl;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/comment-author-avatar/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default function Edit( {
const maxSizeBuffer = Math.floor( maxSize * 2.5 );
const { avatarURL } = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
const { __experimentalDiscussionSettings } = getSettings();
return __experimentalDiscussionSettings;
const { discussionSettings } = getSettings();
return discussionSettings;
} );

const inspectorControls = (
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/comment-template/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export default function CommentTemplateEdit( {
commentsPerPage,
} = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
return getSettings().__experimentalDiscussionSettings;
return getSettings().discussionSettings;
} );

const commentQuery = useCommentQueryArgs( {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/comment-template/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export const useCommentQueryArgs = ( { postId } ) => {
defaultCommentsPage: defaultPage,
} = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
const { __experimentalDiscussionSettings } = getSettings();
return __experimentalDiscussionSettings;
const { discussionSettings } = getSettings();
return discussionSettings;
} );

// Get the number of the default page.
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const __experimentalGetCoreBlocks = () => [
// Register all remaining core blocks.
archives,
audio,
avatar,
button,
buttons,
calendar,
Expand Down Expand Up @@ -252,7 +253,6 @@ export const __experimentalRegisterExperimentalCoreBlocks = process.env
? ( { enableFSEBlocks } = {} ) => {
[
// Experimental blocks.
avatar,
homeLink,
postAuthorName,
queryNoResults,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ function useBlockEditorSettings( settings, hasTemplate ) {
() => ( {
...pick( settings, [
'__experimentalBlockDirectory',
'__experimentalDiscussionSettings',
'__experimentalFeatures',
'__experimentalPreferredStyleVariations',
'__experimentalSetIsInserterOpened',
Expand All @@ -116,6 +115,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
'disableCustomColors',
'disableCustomFontSizes',
'disableCustomGradients',
'discussionSettings',
'enableCustomLineHeight',
'enableCustomSpacing',
'enableCustomUnits',
Expand Down