| @@ 597-619 (lines=23) @@ | ||
| 594 | * @uses register_rest_field |
|
| 595 | * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/ |
|
| 596 | */ |
|
| 597 | function jetpack_post_sharing_register_rest_field() { |
|
| 598 | $post_types = get_post_types( array( 'public' => true ) ); |
|
| 599 | foreach ( $post_types as $post_type ) { |
|
| 600 | register_rest_field( |
|
| 601 | $post_type, |
|
| 602 | 'jetpack_sharing_enabled', |
|
| 603 | array( |
|
| 604 | 'get_callback' => 'jetpack_post_sharing_get_value', |
|
| 605 | 'update_callback' => 'jetpack_post_sharing_update_value', |
|
| 606 | 'schema' => array( |
|
| 607 | 'description' => __( 'Are sharing buttons enabled?', 'jetpack' ), |
|
| 608 | 'type' => 'boolean', |
|
| 609 | ), |
|
| 610 | ) |
|
| 611 | ); |
|
| 612 | ||
| 613 | /** |
|
| 614 | * Ensures all public internal post-types support `sharing` |
|
| 615 | * This feature support flag is used by the REST API and Gutenberg. |
|
| 616 | */ |
|
| 617 | add_post_type_support( $post_type, 'jetpack-sharing-buttons' ); |
|
| 618 | } |
|
| 619 | } |
|
| 620 | ||
| 621 | // Add Sharing post_meta to the REST API Post response. |
|
| 622 | add_action( 'rest_api_init', 'jetpack_post_sharing_register_rest_field' ); |
|
| @@ 670-692 (lines=23) @@ | ||
| 667 | * @uses register_rest_field |
|
| 668 | * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/ |
|
| 669 | */ |
|
| 670 | function jetpack_post_likes_register_rest_field() { |
|
| 671 | $post_types = get_post_types( array( 'public' => true ) ); |
|
| 672 | foreach ( $post_types as $post_type ) { |
|
| 673 | register_rest_field( |
|
| 674 | $post_type, |
|
| 675 | 'jetpack_likes_enabled', |
|
| 676 | array( |
|
| 677 | 'get_callback' => 'jetpack_post_likes_get_value', |
|
| 678 | 'update_callback' => 'jetpack_post_likes_update_value', |
|
| 679 | 'schema' => array( |
|
| 680 | 'description' => __( 'Are Likes enabled?', 'jetpack' ), |
|
| 681 | 'type' => 'boolean', |
|
| 682 | ), |
|
| 683 | ) |
|
| 684 | ); |
|
| 685 | ||
| 686 | /** |
|
| 687 | * Ensures all public internal post-types support `likes` |
|
| 688 | * This feature support flag is used by the REST API and Gutenberg. |
|
| 689 | */ |
|
| 690 | add_post_type_support( $post_type, 'jetpack-post-likes' ); |
|
| 691 | } |
|
| 692 | } |
|
| 693 | ||
| 694 | // Add Likes post_meta to the REST API Post response. |
|
| 695 | add_action( 'rest_api_init', 'jetpack_post_likes_register_rest_field' ); |
|