Code Duplication    Length = 27-31 lines in 2 locations

class.jetpack.php 1 location

@@ 4615-4641 (lines=27) @@
4612
	 *
4613
	 * @return string Assumed site creation date and time.
4614
	 */
4615
	public static function get_assumed_site_creation_date() {
4616
		$earliest_registered_users = get_users( array(
4617
			'role'    => 'administrator',
4618
			'orderby' => 'user_registered',
4619
			'order'   => 'ASC',
4620
			'fields'  => array( 'user_registered' ),
4621
			'number'  => 1,
4622
		) );
4623
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
4624
4625
		$earliest_posts = get_posts( array(
4626
			'posts_per_page' => 1,
4627
			'post_type'      => 'any',
4628
			'post_status'    => 'any',
4629
			'orderby'        => 'date',
4630
			'order'          => 'ASC',
4631
		) );
4632
4633
		// If there are no posts at all, we'll count only on user registration date.
4634
		if ( $earliest_posts ) {
4635
			$earliest_post_date = $earliest_posts[0]->post_date;
4636
		} else {
4637
			$earliest_post_date = PHP_INT_MAX;
4638
		}
4639
4640
		return min( $earliest_registration_date, $earliest_post_date );
4641
	}
4642
4643
	public static function apply_activation_source_to_args( &$args ) {
4644
		list( $activation_source_name, $activation_source_keyword ) = get_option( 'jetpack_activation_source' );

packages/connection/src/Manager.php 1 location

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