From 7b4d386cea4c44f1feb55a147873488e74df9c8b Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Sat, 8 Jun 2024 19:01:11 +0900 Subject: [PATCH 01/13] Global Styles: Fix UI appearing on blocks that don't support text alignment (#62376) Co-authored-by: t-hamano Co-authored-by: aaronrobertshaw Co-authored-by: juanfra Co-authored-by: richtabor --- packages/block-editor/src/components/global-styles/hooks.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-editor/src/components/global-styles/hooks.js b/packages/block-editor/src/components/global-styles/hooks.js index 933d97b0c839e0..7411d84f1fbd49 100644 --- a/packages/block-editor/src/components/global-styles/hooks.js +++ b/packages/block-editor/src/components/global-styles/hooks.js @@ -299,6 +299,7 @@ export function useSettingsForBlockElement( 'fontStyle', 'fontWeight', 'letterSpacing', + 'textAlign', 'textTransform', 'textDecoration', 'writingMode', From acbfacf8a261ea5cbc85b4e57b8169c32d51a408 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Sat, 8 Jun 2024 12:04:59 +0200 Subject: [PATCH 02/13] Replace "Add new post" link text with more meaningful Label (v2) (#62277) * Replace "Add new post" link text with more meaningful 'add_new_item' label of current post type. * Avoid rendering the CreateNewPostLink component itself if postType is falsy * Follow recommendation to use useSelect hook, instead of using select() directly in React components Co-authored-by: carstingaxion Co-authored-by: t-hamano --- .../create-new-post-link.js | 20 +++++++++++-------- .../query/edit/inspector-controls/index.js | 8 +++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/query/edit/inspector-controls/create-new-post-link.js b/packages/block-library/src/query/edit/inspector-controls/create-new-post-link.js index a8be9ed1c8d4fa..58d58a6089aacd 100644 --- a/packages/block-library/src/query/edit/inspector-controls/create-new-post-link.js +++ b/packages/block-library/src/query/edit/inspector-controls/create-new-post-link.js @@ -1,23 +1,27 @@ /** * WordPress dependencies */ -import { __ } from '@wordpress/i18n'; import { createInterpolateElement } from '@wordpress/element'; import { addQueryArgs } from '@wordpress/url'; +import { store as coreStore } from '@wordpress/core-data'; +import { useSelect } from '@wordpress/data'; -const CreateNewPostLink = ( { - attributes: { query: { postType } = {} } = {}, -} ) => { - if ( ! postType ) { - return null; - } +const CreateNewPostLink = ( { postType } ) => { const newPostUrl = addQueryArgs( 'post-new.php', { post_type: postType, } ); + + const addNewItemLabel = useSelect( + ( select ) => { + const { getPostType } = select( coreStore ); + return getPostType( postType )?.labels?.add_new_item; + }, + [ postType ] + ); return (
{ createInterpolateElement( - __( 'Add new post' ), + '' + addNewItemLabel + '', // eslint-disable-next-line jsx-a11y/anchor-has-content { a: } ) } diff --git a/packages/block-library/src/query/edit/inspector-controls/index.js b/packages/block-library/src/query/edit/inspector-controls/index.js index eb5abe9c24d98f..a8b3330f5b4b54 100644 --- a/packages/block-library/src/query/edit/inspector-controls/index.js +++ b/packages/block-library/src/query/edit/inspector-controls/index.js @@ -131,9 +131,11 @@ export default function QueryInspectorControls( props ) { return ( <> - - - + { !! postType && ( + + + + ) } { showSettingsPanel && ( { showInheritControl && ( From 54747e73ccb1fa1bebd4a1b7fa7c3a137cb6f97c Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Sun, 9 Jun 2024 08:41:00 +0530 Subject: [PATCH 03/13] Several typo correction in documentations (#62433) Co-authored-by: shail-mehta Co-authored-by: t-hamano --- docs/contributors/folder-structure.md | 2 +- docs/reference-guides/slotfills/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contributors/folder-structure.md b/docs/contributors/folder-structure.md index cbad182a58f447..e20ba81708a064 100644 --- a/docs/contributors/folder-structure.md +++ b/docs/contributors/folder-structure.md @@ -76,7 +76,7 @@ The following snippet explains how the Gutenberg repository is structured omitti │ Set of documentation pages composing the [Block editor handbook](https://developer.wordpress.org/block-editor/). │ ├── platform-docs - │ Documentation website targetted to non WordPress developpers + │ Documentation website targeted to non WordPress developers │ using Gutenberg in their own applications. │ Deployed on [https://wordpress.org/gutenberg-framework/](https://wordpress.org/gutenberg-framework/). │ diff --git a/docs/reference-guides/slotfills/README.md b/docs/reference-guides/slotfills/README.md index ea324f71b25e83..8b56ed4ce98b41 100644 --- a/docs/reference-guides/slotfills/README.md +++ b/docs/reference-guides/slotfills/README.md @@ -68,7 +68,7 @@ See [core code](https://github.com/WordPress/gutenberg/tree/HEAD/packages/editor ```js export default function PostSummary( { onActionPerformed } ) { const { isRemovedPostStatusPanel } = useSelect( ( select ) => { - // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do + // We use isEditorPanelRemoved to hide the panel if it was programmatically removed. We do // not use isEditorPanelEnabled since this panel should not be disabled through the UI. const { isEditorPanelRemoved, getCurrentPostType } = select( editorStore ); From 2bfdac4ac7bd0981317c4f3efe3d143eeb965631 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Sun, 9 Jun 2024 15:13:22 +0530 Subject: [PATCH 04/13] Add @global PHP documentation (#60539) --- packages/block-library/src/site-logo/index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/block-library/src/site-logo/index.php b/packages/block-library/src/site-logo/index.php index ea6d9f1f8d97c9..915563461e30ce 100644 --- a/packages/block-library/src/site-logo/index.php +++ b/packages/block-library/src/site-logo/index.php @@ -159,6 +159,8 @@ function _sync_custom_logo_to_site_logo( $value ) { * * @since 5.8.0 * + * @global array $_ignore_site_logo_changes + * * @param array $old_value Previous theme mod settings. * @param array $value Updated theme mod settings. */ @@ -179,6 +181,8 @@ function _delete_site_logo_on_remove_custom_logo( $old_value, $value ) { * Deletes the site logo when all theme mods are being removed. * * @since 5.8.0 + * + * @global array $_ignore_site_logo_changes */ function _delete_site_logo_on_remove_theme_mods() { global $_ignore_site_logo_changes; @@ -211,6 +215,8 @@ function _delete_site_logo_on_remove_custom_logo_on_setup_theme() { * Removes the custom_logo theme-mod when the site_logo option gets deleted. * * @since 5.9.0 + * + * @global array $_ignore_site_logo_changes */ function _delete_custom_logo_on_remove_site_logo() { global $_ignore_site_logo_changes; From 5ca6eed30c2543ee940b5e45f784cc1536ac9422 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Sun, 9 Jun 2024 15:14:11 +0530 Subject: [PATCH 05/13] Corrected @since Order in Php Docs (#61992) Co-authored-by: shail-mehta Co-authored-by: fabiankaegy --- packages/e2e-tests/plugins/class-test-widget.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/e2e-tests/plugins/class-test-widget.php b/packages/e2e-tests/plugins/class-test-widget.php index 12b1d2f34a6fa4..450c97b1163967 100644 --- a/packages/e2e-tests/plugins/class-test-widget.php +++ b/packages/e2e-tests/plugins/class-test-widget.php @@ -56,12 +56,13 @@ public function form( $instance ) { /** * Handles updating settings for the current widget instance. * + * @since 4.8.1 + * * @param array $new_instance New settings for this instance as input by the user via * WP_Widget::form(). * @param array $old_instance Old settings for this instance. * * @return array Settings to save or bool false to cancel saving. - * @since 4.8.1 */ // @codingStandardsIgnoreStart – to prevent phpcs from complaining about unused function argument. public function update( $new_instance, $old_instance ) { From b0c9f4be156c505eb66f96b425543381d0d3078f Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Mon, 10 Jun 2024 08:40:37 +0300 Subject: [PATCH 06/13] Editor: Make revisions more prominent (#62323) Unlinked contributors: ppolo99, smithjw1. Co-authored-by: ntsekouras Co-authored-by: creativecoder Co-authored-by: Mamaduka Co-authored-by: jasmussen Co-authored-by: annezazu Co-authored-by: aaronjorbin Co-authored-by: hrkhal --- .../components/post-last-revision/index.js | 37 +++++++++++++++---- .../components/post-last-revision/style.scss | 4 ++ .../src/components/sidebar/post-summary.js | 2 + 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/packages/editor/src/components/post-last-revision/index.js b/packages/editor/src/components/post-last-revision/index.js index 97031106772ada..73bcb7c0e026f9 100644 --- a/packages/editor/src/components/post-last-revision/index.js +++ b/packages/editor/src/components/post-last-revision/index.js @@ -11,15 +11,11 @@ import { addQueryArgs } from '@wordpress/url'; * Internal dependencies */ import PostLastRevisionCheck from './check'; +import PostPanelRow from '../post-panel-row'; import { store as editorStore } from '../../store'; -/** - * Renders the component for displaying the last revision of a post. - * - * @return {Component} The component to be rendered. - */ -function PostLastRevision() { - const { lastRevisionId, revisionsCount } = useSelect( ( select ) => { +function usePostLastRevisionInfo() { + return useSelect( ( select ) => { const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } = select( editorStore ); return { @@ -27,6 +23,15 @@ function PostLastRevision() { revisionsCount: getCurrentPostRevisionsCount(), }; }, [] ); +} + +/** + * Renders the component for displaying the last revision of a post. + * + * @return {Component} The component to be rendered. + */ +function PostLastRevision() { + const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo(); return ( @@ -47,4 +52,22 @@ function PostLastRevision() { ); } +export function PrivatePostLastRevision() { + const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo(); + return ( + + + + label={ __( 'First page' ) } + icon={ previous } + size="compact" + /> + label={ __( 'Previous page' ) } + icon={ chevronLeft } + size="compact" + /> { sprintf( @@ -76,19 +77,19 @@ export default function Pagination( { onClick={ () => changePage( currentPage + 1 ) } __experimentalIsFocusable disabled={ disabled || currentPage === numPages } - aria-label={ __( 'Next page' ) } - > - › - + label={ __( 'Next page' ) } + icon={ chevronRight } + size="compact" + /> + label={ __( 'Last page' ) } + icon={ next } + size="compact" + /> ); From 9c3dabc595101bd285723a4fac266c132fbd489c Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Mon, 10 Jun 2024 17:07:41 +0800 Subject: [PATCH 10/13] Fix applying bindings or pattern overrides to button blocks with empty text (#62220) * Dynamically check button text and avoid rendering a button when empty * Handle both anchor and button tags * Fix lint issues * Address review feedback * Simplify checks for empty content * Check for comment tokens * Update native test snapshots * Update initial HTML native test snippet ---- Co-authored-by: talldan Co-authored-by: dmsnell Co-authored-by: kevin940726 Co-authored-by: SantosGuillamot --- lib/blocks.php | 1 + packages/block-library/src/button/index.php | 80 +++++++++++++++++++ packages/block-library/src/button/save.js | 4 - .../test/__snapshots__/edit.native.js.snap | 40 +++++++--- .../src/buttons/test/edit.native.js | 11 +-- 5 files changed, 117 insertions(+), 19 deletions(-) create mode 100644 packages/block-library/src/button/index.php diff --git a/lib/blocks.php b/lib/blocks.php index 679219cc6ff774..c3fdb26700c58c 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -48,6 +48,7 @@ function gutenberg_reregister_core_block_types() { 'archives.php' => 'core/archives', 'avatar.php' => 'core/avatar', 'block.php' => 'core/block', + 'button.php' => 'core/button', 'calendar.php' => 'core/calendar', 'categories.php' => 'core/categories', 'cover.php' => 'core/cover', diff --git a/packages/block-library/src/button/index.php b/packages/block-library/src/button/index.php new file mode 100644 index 00000000000000..f272fa9eb62b14 --- /dev/null +++ b/packages/block-library/src/button/index.php @@ -0,0 +1,80 @@ +` or `