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

packages/module-likes/legacy/likes.php 1 location

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