Code Duplication    Length = 27-31 lines in 2 locations

class.jetpack.php 1 location

@@ 4636-4662 (lines=27) @@
4633
	 *
4634
	 * @return string Assumed site creation date and time.
4635
	 */
4636
	public static function get_assumed_site_creation_date() {
4637
		$earliest_registered_users = get_users( array(
4638
			'role'    => 'administrator',
4639
			'orderby' => 'user_registered',
4640
			'order'   => 'ASC',
4641
			'fields'  => array( 'user_registered' ),
4642
			'number'  => 1,
4643
		) );
4644
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
4645
4646
		$earliest_posts = get_posts( array(
4647
			'posts_per_page' => 1,
4648
			'post_type'      => 'any',
4649
			'post_status'    => 'any',
4650
			'orderby'        => 'date',
4651
			'order'          => 'ASC',
4652
		) );
4653
4654
		// If there are no posts at all, we'll count only on user registration date.
4655
		if ( $earliest_posts ) {
4656
			$earliest_post_date = $earliest_posts[0]->post_date;
4657
		} else {
4658
			$earliest_post_date = PHP_INT_MAX;
4659
		}
4660
4661
		return min( $earliest_registration_date, $earliest_post_date );
4662
	}
4663
4664
	public static function apply_activation_source_to_args( &$args ) {
4665
		list( $activation_source_name, $activation_source_keyword ) = get_option( 'jetpack_activation_source' );

packages/connection/src/Manager.php 1 location

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