REST API: Register Likes/Sharing fields for all post types#11516
REST API: Register Likes/Sharing fields for all post types#11516
Conversation
|
Caution: This PR has changes that must be merged to WordPress.com |
|
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: April 2, 2019. |
jeherve
left a comment
There was a problem hiding this comment.
Hey, it's me, nit-picking again. We're working on adding linting to our pre-commit hook (see #11515 for more info), but until then I'm afraid you'll need to fix those manually. I would do it myself but I don't want to overwrite your wpcom changes with Fusion by mistake.
Here is what I think should be changed to please the linter:
diff --git a/modules/likes.php b/modules/likes.php
index 0594c469e..b2e5de545 100644
--- a/modules/likes.php
+++ b/modules/likes.php
@@ -622,15 +622,16 @@ function jetpack_post_likes_update_value( $enable_post_likes, $post_object ) {
*/
function jetpack_post_likes_register_rest_field() {
$post_types = get_post_types( array( 'public' => true ) );
- foreach( $post_types as $post_type ) {
+ foreach ( $post_types as $post_type ) {
register_rest_field(
- $post_type, 'jetpack_likes_enabled',
+ $post_type,
+ 'jetpack_likes_enabled',
array(
- 'get_callback' => 'jetpack_post_likes_get_value',
+ 'get_callback' => 'jetpack_post_likes_get_value',
'update_callback' => 'jetpack_post_likes_update_value',
- 'schema' => array(
- 'description' => __( 'Are Likes enabled?' ),
- 'type' => 'boolean'
+ 'schema' => array(
+ 'description' => __( 'Are Likes enabled?', 'jetpack' ),
+ 'type' => 'boolean',
),
)
);
diff --git a/modules/sharedaddy/sharing.php b/modules/sharedaddy/sharing.php
index 33de9d3d9..b2d4872cc 100644
--- a/modules/sharedaddy/sharing.php
+++ b/modules/sharedaddy/sharing.php
@@ -591,15 +591,16 @@ function jetpack_post_sharing_update_value( $enable_sharing, $post_object ) {
*/
function jetpack_post_sharing_register_rest_field() {
$post_types = get_post_types( array( 'public' => true ) );
- foreach( $post_types as $post_type ) {
+ foreach ( $post_types as $post_type ) {
register_rest_field(
- $post_type, 'jetpack_sharing_enabled',
+ $post_type,
+ 'jetpack_sharing_enabled',
array(
- 'get_callback' => 'jetpack_post_sharing_get_value',
+ 'get_callback' => 'jetpack_post_sharing_get_value',
'update_callback' => 'jetpack_post_sharing_update_value',
- 'schema' => array(
- 'description' => __( 'Are sharing buttons enabled?' ),
- 'type' => 'boolean'
+ 'schema' => array(
+ 'description' => __( 'Are sharing buttons enabled?', 'jetpack' ),
+ 'type' => 'boolean',
),
)
);Other than that, it works well and is a good addition. It should be good to go.
Add Jetpack textdomain to translation string Co-Authored-By: codebykat <kat@codebykat.com>
|
codebykat, Your synced wpcom patch D25225-code has been updated. |
Add Jetpack textdomain to translation string Co-Authored-By: codebykat <kat@codebykat.com>
|
codebykat, Your synced wpcom patch D25225-code has been updated. |
|
codebykat, Your synced wpcom patch D25225-code has been updated. |
|
Nits fixed! Thanks @jeherve ! |
jeherve
left a comment
There was a problem hiding this comment.
This should now be good to merge.
* Initial Changelog for 7.2 * Testing list: add mention of IE11 testing * Initial Changelog for 7.2 * Testing list: add mention of IE11 testing * Add CL for #11224 * Add CL for #11426 * Add CL for #11442 * Add testing instructions for #11224 * Add CL for #11451 * Reclassify CL item * Add testing instructions for #11451 * Add CL for #11486 * Add CL for #11418 * Add CL for #11524 * Add CL and testing instructions for #11449 * Add CL for #11460 * Add CL for #11520 and #11582 * Add CL for #11531 * Add CL #11644 * Add testing instructions for #11644 * Add testing instructions for #11644 * Add CL for #11618 * Uniform changelog lines * CL #11679 * CL #11661 * CL #11654 * CL #11645 * CL #11643 * CL #11636 * CL #11635 and for other PHPCS commits * CL #11627 * CL #11626 * CL #11598 * CL #11596 * Remove nested items for shortcopy. I don't believe the detailed list is helpful * CL #11570 * CL #11569 * CL #11560 * CL #11558 * CL #11555 * CL #6704 * CL #11298 * CL #11324 * CL #11443 * CL #11484 * CL #11516 * CL #11529 * Expand Ads block enhancement CL item
Changes proposed in this Pull Request:
In #11298, metadata to check whether sharing and Like buttons are enabled was added to post endpoints. I thought at the time that hooking it to the "post" type meant "posts and pages", but it turns out it does not.
This PR follows the pre-existing pattern of enabling this functionality for all public post types (this is the same logic used to add the metaboxes to the admin screen).
Testing instructions:
jetpack_likes_enabledandjetpack_sharing_enabledshow under the meta keys:Proposed changelog entry for your changes: