forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from rishishah-multidots/try/inline-block-comm…
…enting made changes as per the feedback
- Loading branch information
Showing
8 changed files
with
86 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* PHP and WordPress configuration compatibility functions for the Gutenberg | ||
* editor plugin changes related to REST API. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
die( 'Silence is golden.' ); | ||
} | ||
|
||
/** | ||
* Updates the comment type in the REST API for WordPress version 6.7. | ||
* | ||
* This function is used as a filter callback for the 'rest_pre_insert_comment' hook. | ||
* It checks if the 'comment_type' parameter is set to 'block_comment' in the REST API request, | ||
* and if so, updates the 'comment_type' and 'comment_approved' properties of the prepared comment. | ||
* | ||
* @param array $prepared_comment The prepared comment data. | ||
* @param WP_REST_Request $request The REST API request object. | ||
* @return array The updated prepared comment data. | ||
*/ | ||
if ( ! function_exists( 'update_comment_type_in_rest_api_6_8' ) && gutenberg_is_experiment_enabled( 'gutenberg-block-comment' ) ) { | ||
function update_comment_type_in_rest_api_6_8( $prepared_comment, $request ) { | ||
if ( ! empty( $request['comment_type'] ) && 'block_comment' === $request['comment_type'] ) { | ||
$prepared_comment['comment_type'] = $request['comment_type']; | ||
$prepared_comment['comment_approved'] = $request['comment_approved']; | ||
} | ||
|
||
return $prepared_comment; | ||
} | ||
add_filter( 'rest_pre_insert_comment', 'update_comment_type_in_rest_api_6_8', 10, 2 ); | ||
} | ||
|
||
/** | ||
* Updates the comment type for avatars in the WordPress REST API. | ||
* | ||
* This function adds the 'block_comment' type to the list of comment types | ||
* for which avatars should be retrieved in the WordPress REST API. | ||
* | ||
* @param array $comment_type The array of comment types. | ||
* @return array The updated array of comment types. | ||
*/ | ||
if ( ! function_exists( 'update_get_avatar_comment_type' ) && gutenberg_is_experiment_enabled( 'gutenberg-block-comment' ) ) { | ||
function update_get_avatar_comment_type( $comment_type ) { | ||
$comment_type[] = 'block_comment'; | ||
return $comment_type; | ||
} | ||
add_filter( 'get_avatar_comment_types', 'update_get_avatar_comment_type' ); | ||
} |
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
File renamed without changes.
File renamed without changes.
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