Code Duplication    Length = 27-31 lines in 2 locations

class.jetpack.php 1 location

@@ 4556-4582 (lines=27) @@
4553
	 *
4554
	 * @return string Assumed site creation date and time.
4555
	 */
4556
	public static function get_assumed_site_creation_date() {
4557
		$earliest_registered_users = get_users( array(
4558
			'role'    => 'administrator',
4559
			'orderby' => 'user_registered',
4560
			'order'   => 'ASC',
4561
			'fields'  => array( 'user_registered' ),
4562
			'number'  => 1,
4563
		) );
4564
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
4565
4566
		$earliest_posts = get_posts( array(
4567
			'posts_per_page' => 1,
4568
			'post_type'      => 'any',
4569
			'post_status'    => 'any',
4570
			'orderby'        => 'date',
4571
			'order'          => 'ASC',
4572
		) );
4573
4574
		// If there are no posts at all, we'll count only on user registration date.
4575
		if ( $earliest_posts ) {
4576
			$earliest_post_date = $earliest_posts[0]->post_date;
4577
		} else {
4578
			$earliest_post_date = PHP_INT_MAX;
4579
		}
4580
4581
		return min( $earliest_registration_date, $earliest_post_date );
4582
	}
4583
4584
	public static function apply_activation_source_to_args( &$args ) {
4585
		list( $activation_source_name, $activation_source_keyword ) = get_option( 'jetpack_activation_source' );

packages/connection/src/Manager.php 1 location

@@ 986-1016 (lines=31) @@
983
	 *
984
	 * @return string Assumed site creation date and time.
985
	 */
986
	public function get_assumed_site_creation_date() {
987
		$earliest_registered_users  = get_users(
988
			array(
989
				'role'    => 'administrator',
990
				'orderby' => 'user_registered',
991
				'order'   => 'ASC',
992
				'fields'  => array( 'user_registered' ),
993
				'number'  => 1,
994
			)
995
		);
996
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
997
998
		$earliest_posts = get_posts(
999
			array(
1000
				'posts_per_page' => 1,
1001
				'post_type'      => 'any',
1002
				'post_status'    => 'any',
1003
				'orderby'        => 'date',
1004
				'order'          => 'ASC',
1005
			)
1006
		);
1007
1008
		// If there are no posts at all, we'll count only on user registration date.
1009
		if ( $earliest_posts ) {
1010
			$earliest_post_date = $earliest_posts[0]->post_date;
1011
		} else {
1012
			$earliest_post_date = PHP_INT_MAX;
1013
		}
1014
1015
		return min( $earliest_registration_date, $earliest_post_date );
1016
	}
1017
1018
	/**
1019
	 * Adds the activation source string as a parameter to passed arguments.