Code Duplication    Length = 27-31 lines in 2 locations

class.jetpack.php 1 location

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

packages/connection/src/Manager.php 1 location

@@ 371-401 (lines=31) @@
368
	 *
369
	 * @return string Assumed site creation date and time.
370
	 */
371
	public function get_assumed_site_creation_date() {
372
		$earliest_registered_users  = get_users(
373
			array(
374
				'role'    => 'administrator',
375
				'orderby' => 'user_registered',
376
				'order'   => 'ASC',
377
				'fields'  => array( 'user_registered' ),
378
				'number'  => 1,
379
			)
380
		);
381
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
382
383
		$earliest_posts = get_posts(
384
			array(
385
				'posts_per_page' => 1,
386
				'post_type'      => 'any',
387
				'post_status'    => 'any',
388
				'orderby'        => 'date',
389
				'order'          => 'ASC',
390
			)
391
		);
392
393
		// If there are no posts at all, we'll count only on user registration date.
394
		if ( $earliest_posts ) {
395
			$earliest_post_date = $earliest_posts[0]->post_date;
396
		} else {
397
			$earliest_post_date = PHP_INT_MAX;
398
		}
399
400
		return min( $earliest_registration_date, $earliest_post_date );
401
	}
402
403
	public static function apply_activation_source_to_args( $args ) {
404
		list( $activation_source_name, $activation_source_keyword ) = get_option( 'jetpack_activation_source' );