-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
250778b
commit 8be0a42
Showing
7 changed files
with
104 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "core/post-comment-content", | ||
"category": "design", | ||
"usesContext": [ "commentId" ], | ||
"supports": { | ||
"html": false | ||
} | ||
} |
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,19 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useEntityProp } from '@wordpress/core-data'; | ||
|
||
// TODO: JSDOC types | ||
export default function Edit( { attributes, context } ) { | ||
const { className } = attributes; | ||
const { commentId } = context; | ||
|
||
const [ content ] = useEntityProp( | ||
'root', | ||
'comment', | ||
'content', | ||
commentId | ||
); | ||
|
||
return <p className={ className }>{ content }</p>; | ||
} |
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,20 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import metadata from './block.json'; | ||
import edit from './edit'; | ||
|
||
const { name } = metadata; | ||
export { metadata, name }; | ||
|
||
export const settings = { | ||
title: __( 'Post Comment Content' ), | ||
description: __( 'Post Comment Content' ), | ||
edit, | ||
parent: [ 'core/post-comment' ], | ||
}; |
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,35 @@ | ||
<?php | ||
/** | ||
* Server-side rendering of the `core/post-comment-content` block. | ||
* | ||
* @package WordPress | ||
*/ | ||
|
||
/** | ||
* Renders the `core/post-comment-content` block on the server. | ||
* | ||
* @param array $attributes Block attributes. | ||
* @param string $content Block default content. | ||
* @param WP_Block $block Block instance. | ||
* @return string Return the post comment's content. | ||
*/ | ||
function render_block_core_post_comment_content( $attributes, $content, $block ) { | ||
if ( ! isset( $block->context['commentId'] ) ) { | ||
return ''; | ||
} | ||
|
||
return sprintf( '<div>%1$s</div>', get_comment_text( $block->context['commentId'] ) ); | ||
} | ||
|
||
/** | ||
* Registers the `core/post-comment-content` block on the server. | ||
*/ | ||
function register_block_core_post_comment_content() { | ||
register_block_type_from_metadata( | ||
__DIR__ . '/post-comment-content', | ||
array( | ||
'render_callback' => 'render_block_core_post_comment_content', | ||
) | ||
); | ||
} | ||
add_action( 'init', 'register_block_core_post_comment_content' ); |
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