Code Duplication    Length = 27-31 lines in 2 locations

class.jetpack.php 1 location

@@ 4515-4541 (lines=27) @@
4512
	 *
4513
	 * @return string Assumed site creation date and time.
4514
	 */
4515
	public static function get_assumed_site_creation_date() {
4516
		$earliest_registered_users = get_users( array(
4517
			'role'    => 'administrator',
4518
			'orderby' => 'user_registered',
4519
			'order'   => 'ASC',
4520
			'fields'  => array( 'user_registered' ),
4521
			'number'  => 1,
4522
		) );
4523
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
4524
4525
		$earliest_posts = get_posts( array(
4526
			'posts_per_page' => 1,
4527
			'post_type'      => 'any',
4528
			'post_status'    => 'any',
4529
			'orderby'        => 'date',
4530
			'order'          => 'ASC',
4531
		) );
4532
4533
		// If there are no posts at all, we'll count only on user registration date.
4534
		if ( $earliest_posts ) {
4535
			$earliest_post_date = $earliest_posts[0]->post_date;
4536
		} else {
4537
			$earliest_post_date = PHP_INT_MAX;
4538
		}
4539
4540
		return min( $earliest_registration_date, $earliest_post_date );
4541
	}
4542
4543
	public static function apply_activation_source_to_args( &$args ) {
4544
		list( $activation_source_name, $activation_source_keyword ) = get_option( 'jetpack_activation_source' );

packages/connection/src/Manager.php 1 location

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