Code Duplication    Length = 27-31 lines in 2 locations

class.jetpack.php 1 location

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

packages/connection/src/Manager.php 1 location

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