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

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