| @@ 623-639 (lines=17) @@ | ||
| 620 | * @uses register_rest_field |
|
| 621 | * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/ |
|
| 622 | */ |
|
| 623 | function jetpack_post_likes_register_rest_field() { |
|
| 624 | $post_types = get_post_types( array( 'public' => true ) ); |
|
| 625 | foreach ( $post_types as $post_type ) { |
|
| 626 | register_rest_field( |
|
| 627 | $post_type, |
|
| 628 | 'jetpack_likes_enabled', |
|
| 629 | array( |
|
| 630 | 'get_callback' => 'jetpack_post_likes_get_value', |
|
| 631 | 'update_callback' => 'jetpack_post_likes_update_value', |
|
| 632 | 'schema' => array( |
|
| 633 | 'description' => __( 'Are Likes enabled?', 'jetpack' ), |
|
| 634 | 'type' => 'boolean', |
|
| 635 | ), |
|
| 636 | ) |
|
| 637 | ); |
|
| 638 | } |
|
| 639 | } |
|
| 640 | ||
| 641 | // Add Likes post_meta to the REST API Post response. |
|
| 642 | add_action( 'rest_api_init', 'jetpack_post_likes_register_rest_field' ); |
|
| @@ 592-608 (lines=17) @@ | ||
| 589 | * @uses register_rest_field |
|
| 590 | * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/ |
|
| 591 | */ |
|
| 592 | function jetpack_post_sharing_register_rest_field() { |
|
| 593 | $post_types = get_post_types( array( 'public' => true ) ); |
|
| 594 | foreach ( $post_types as $post_type ) { |
|
| 595 | register_rest_field( |
|
| 596 | $post_type, |
|
| 597 | 'jetpack_sharing_enabled', |
|
| 598 | array( |
|
| 599 | 'get_callback' => 'jetpack_post_sharing_get_value', |
|
| 600 | 'update_callback' => 'jetpack_post_sharing_update_value', |
|
| 601 | 'schema' => array( |
|
| 602 | 'description' => __( 'Are sharing buttons enabled?', 'jetpack' ), |
|
| 603 | 'type' => 'boolean', |
|
| 604 | ), |
|
| 605 | ) |
|
| 606 | ); |
|
| 607 | } |
|
| 608 | } |
|
| 609 | ||
| 610 | // Add Sharing post_meta to the REST API Post response. |
|
| 611 | add_action( 'rest_api_init', 'jetpack_post_sharing_register_rest_field' ); |
|