Code Duplication    Length = 23-23 lines in 2 locations

modules/sharedaddy/sharing.php 1 location

@@ 596-618 (lines=23) @@
593
 * @uses register_rest_field
594
 * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/
595
 */
596
function jetpack_post_sharing_register_rest_field() {
597
	$post_types = get_post_types( array( 'public' => true ) );
598
	foreach ( $post_types as $post_type ) {
599
		register_rest_field(
600
			$post_type,
601
			'jetpack_sharing_enabled',
602
			array(
603
				'get_callback'    => 'jetpack_post_sharing_get_value',
604
				'update_callback' => 'jetpack_post_sharing_update_value',
605
				'schema'          => array(
606
					'description' => __( 'Are sharing buttons enabled?', 'jetpack' ),
607
					'type'        => 'boolean',
608
				),
609
			)
610
		);
611
612
		/**
613
		 * Ensures all public internal post-types support `sharing`
614
		 * This feature support flag is used by the REST API and Gutenberg.
615
		 */
616
		add_post_type_support( $post_type, 'jetpack-sharing-buttons' );
617
	}
618
}
619
620
// Add Sharing post_meta to the REST API Post response.
621
add_action( 'rest_api_init', 'jetpack_post_sharing_register_rest_field' );

modules/likes.php 1 location

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