Code Duplication    Length = 27-31 lines in 2 locations

class.jetpack.php 1 location

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

packages/connection/src/Manager.php 1 location

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