Code Duplication    Length = 23-23 lines in 2 locations

modules/sharedaddy/sharing.php 1 location

@@ 592-614 (lines=23) @@
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
		 * Ensures all public internal post-types support `sharing`
610
		 * This feature support flag is used by the REST API and Gutenberg.
611
		 */
612
		add_post_type_support( $post_type, 'jetpack-sharing-buttons' );
613
	}
614
}
615
616
// Add Sharing post_meta to the REST API Post response.
617
add_action( 'rest_api_init', 'jetpack_post_sharing_register_rest_field' );

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