Code Duplication    Length = 23-23 lines in 2 locations

modules/sharedaddy/sharing.php 1 location

@@ 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' );

modules/likes.php 1 location

@@ 622-644 (lines=23) @@
619
 * @uses register_rest_field
620
 * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/
621
 */
622
function jetpack_post_likes_register_rest_field() {
623
	$post_types = get_post_types( array( 'public' => true ) );
624
	foreach ( $post_types as $post_type ) {
625
		register_rest_field(
626
			$post_type,
627
			'jetpack_likes_enabled',
628
			array(
629
				'get_callback'    => 'jetpack_post_likes_get_value',
630
				'update_callback' => 'jetpack_post_likes_update_value',
631
				'schema'          => array(
632
					'description' => __( 'Are Likes enabled?', 'jetpack' ),
633
					'type'        => 'boolean',
634
				),
635
			)
636
		);
637
638
		/**
639
		 * Ensures all public internal post-types support `likes`
640
		 * This feature support flag is used by the REST API and Gutenberg.
641
		 */
642
		add_post_type_support( $post_type, 'jetpack-post-likes' );
643
	}
644
}
645
646
// Add Likes post_meta to the REST API Post response.
647
add_action( 'rest_api_init', 'jetpack_post_likes_register_rest_field' );