-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into update/welcome-guide-copy
- Loading branch information
Showing
37 changed files
with
350 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lib/compat/wordpress-6.3/class-gutenberg-rest-blocks-controller.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Reusable blocks REST API: WP_REST_Blocks_Controller class | ||
* | ||
* @package WordPress | ||
* @subpackage REST_API | ||
* @since 5.0.0 | ||
*/ | ||
|
||
/** | ||
* Controller which provides a REST endpoint for the editor to read, create, | ||
* edit and delete reusable blocks. Blocks are stored as posts with the wp_block | ||
* post type. | ||
* | ||
* @since 5.0.0 | ||
* | ||
* @see WP_REST_Posts_Controller | ||
* @see WP_REST_Controller | ||
*/ | ||
class Gutenberg_REST_Blocks_Controller extends WP_REST_Blocks_Controller { | ||
/** | ||
* Filters a response based on the context defined in the schema. | ||
* | ||
* @since 5.0.0 | ||
* @since 6.3 Adds the `wp_pattern_sync_status` property to the response. | ||
* | ||
* @param array $data Response data to filter. | ||
* @param string $context Context defined in the schema. | ||
* @return array Filtered response. | ||
*/ | ||
public function filter_response_by_context( $data, $context ) { | ||
$data = parent::filter_response_by_context( $data, $context ); | ||
|
||
/* | ||
* Remove `title.rendered` and `content.rendered` from the response. It | ||
* doesn't make sense for a reusable block to have rendered content on its | ||
* own, since rendering a block requires it to be inside a post or a page. | ||
*/ | ||
unset( $data['title']['rendered'] ); | ||
unset( $data['content']['rendered'] ); | ||
|
||
// Add the core wp_pattern_sync_status meta as top level property to the response. | ||
$data['wp_pattern_sync_status'] = isset( $data['meta']['wp_pattern_sync_status'] ) ? $data['meta']['wp_pattern_sync_status'] : ''; | ||
unset( $data['meta']['wp_pattern_sync_status'] ); | ||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/block-editor/src/components/inserter/reusable-block-rename-hint.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button } from '@wordpress/components'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { focus } from '@wordpress/dom'; | ||
import { useRef } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { close } from '@wordpress/icons'; | ||
import { store as preferencesStore } from '@wordpress/preferences'; | ||
|
||
const PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible'; | ||
|
||
export default function ReusableBlocksRenameHint() { | ||
const isReusableBlocksRenameHint = useSelect( | ||
( select ) => | ||
select( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true, | ||
[] | ||
); | ||
|
||
const ref = useRef(); | ||
|
||
const { set: setPreference } = useDispatch( preferencesStore ); | ||
if ( ! isReusableBlocksRenameHint ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div ref={ ref } className="reusable-blocks-menu-items__rename-hint"> | ||
<div className="reusable-blocks-menu-items__rename-hint-content"> | ||
{ __( | ||
'Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.' | ||
) } | ||
</div> | ||
<Button | ||
className="reusable-blocks-menu-items__rename-hint-dismiss" | ||
icon={ close } | ||
iconSize="16" | ||
label={ __( 'Dismiss hint' ) } | ||
onClick={ () => { | ||
// Retain focus when dismissing the element. | ||
const previousElement = focus.tabbable.findPrevious( | ||
ref.current | ||
); | ||
previousElement?.focus(); | ||
setPreference( 'core', PREFERENCE_NAME, false ); | ||
} } | ||
showTooltip={ false } | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.