Code Duplication    Length = 27-31 lines in 2 locations

packages/connection/src/Manager.php 1 location

@@ 935-965 (lines=31) @@
932
	 *
933
	 * @return string Assumed site creation date and time.
934
	 */
935
	public function get_assumed_site_creation_date() {
936
		$earliest_registered_users  = get_users(
937
			array(
938
				'role'    => 'administrator',
939
				'orderby' => 'user_registered',
940
				'order'   => 'ASC',
941
				'fields'  => array( 'user_registered' ),
942
				'number'  => 1,
943
			)
944
		);
945
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
946
947
		$earliest_posts = get_posts(
948
			array(
949
				'posts_per_page' => 1,
950
				'post_type'      => 'any',
951
				'post_status'    => 'any',
952
				'orderby'        => 'date',
953
				'order'          => 'ASC',
954
			)
955
		);
956
957
		// If there are no posts at all, we'll count only on user registration date.
958
		if ( $earliest_posts ) {
959
			$earliest_post_date = $earliest_posts[0]->post_date;
960
		} else {
961
			$earliest_post_date = PHP_INT_MAX;
962
		}
963
964
		return min( $earliest_registration_date, $earliest_post_date );
965
	}
966
967
	/**
968
	 * Adds the activation source string as a parameter to passed arguments.

class.jetpack.php 1 location

@@ 4591-4617 (lines=27) @@
4588
	 *
4589
	 * @return string Assumed site creation date and time.
4590
	 */
4591
	public static function get_assumed_site_creation_date() {
4592
		$earliest_registered_users = get_users( array(
4593
			'role'    => 'administrator',
4594
			'orderby' => 'user_registered',
4595
			'order'   => 'ASC',
4596
			'fields'  => array( 'user_registered' ),
4597
			'number'  => 1,
4598
		) );
4599
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
4600
4601
		$earliest_posts = get_posts( array(
4602
			'posts_per_page' => 1,
4603
			'post_type'      => 'any',
4604
			'post_status'    => 'any',
4605
			'orderby'        => 'date',
4606
			'order'          => 'ASC',
4607
		) );
4608
4609
		// If there are no posts at all, we'll count only on user registration date.
4610
		if ( $earliest_posts ) {
4611
			$earliest_post_date = $earliest_posts[0]->post_date;
4612
		} else {
4613
			$earliest_post_date = PHP_INT_MAX;
4614
		}
4615
4616
		return min( $earliest_registration_date, $earliest_post_date );
4617
	}
4618
4619
	public static function apply_activation_source_to_args( &$args ) {
4620
		list( $activation_source_name, $activation_source_keyword ) = get_option( 'jetpack_activation_source' );