Code Duplication    Length = 27-31 lines in 2 locations

class.jetpack.php 1 location

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

packages/connection/src/Manager.php 1 location

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