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

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