Code Duplication    Length = 27-31 lines in 2 locations

packages/connection/src/Manager.php 1 location

@@ 973-1003 (lines=31) @@
970
	 *
971
	 * @return string Assumed site creation date and time.
972
	 */
973
	public function get_assumed_site_creation_date() {
974
		$earliest_registered_users  = get_users(
975
			array(
976
				'role'    => 'administrator',
977
				'orderby' => 'user_registered',
978
				'order'   => 'ASC',
979
				'fields'  => array( 'user_registered' ),
980
				'number'  => 1,
981
			)
982
		);
983
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
984
985
		$earliest_posts = get_posts(
986
			array(
987
				'posts_per_page' => 1,
988
				'post_type'      => 'any',
989
				'post_status'    => 'any',
990
				'orderby'        => 'date',
991
				'order'          => 'ASC',
992
			)
993
		);
994
995
		// If there are no posts at all, we'll count only on user registration date.
996
		if ( $earliest_posts ) {
997
			$earliest_post_date = $earliest_posts[0]->post_date;
998
		} else {
999
			$earliest_post_date = PHP_INT_MAX;
1000
		}
1001
1002
		return min( $earliest_registration_date, $earliest_post_date );
1003
	}
1004
1005
	/**
1006
	 * Adds the activation source string as a parameter to passed arguments.

class.jetpack.php 1 location

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