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

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