Code Duplication    Length = 27-31 lines in 2 locations

class.jetpack.php 1 location

@@ 4681-4707 (lines=27) @@
4678
	 *
4679
	 * @return string Assumed site creation date and time.
4680
	 */
4681
	public static function get_assumed_site_creation_date() {
4682
		$earliest_registered_users = get_users( array(
4683
			'role'    => 'administrator',
4684
			'orderby' => 'user_registered',
4685
			'order'   => 'ASC',
4686
			'fields'  => array( 'user_registered' ),
4687
			'number'  => 1,
4688
		) );
4689
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
4690
4691
		$earliest_posts = get_posts( array(
4692
			'posts_per_page' => 1,
4693
			'post_type'      => 'any',
4694
			'post_status'    => 'any',
4695
			'orderby'        => 'date',
4696
			'order'          => 'ASC',
4697
		) );
4698
4699
		// If there are no posts at all, we'll count only on user registration date.
4700
		if ( $earliest_posts ) {
4701
			$earliest_post_date = $earliest_posts[0]->post_date;
4702
		} else {
4703
			$earliest_post_date = PHP_INT_MAX;
4704
		}
4705
4706
		return min( $earliest_registration_date, $earliest_post_date );
4707
	}
4708
4709
	public static function apply_activation_source_to_args( &$args ) {
4710
		list( $activation_source_name, $activation_source_keyword ) = get_option( 'jetpack_activation_source' );

packages/connection/src/Manager.php 1 location

@@ 1025-1055 (lines=31) @@
1022
	 *
1023
	 * @return string Assumed site creation date and time.
1024
	 */
1025
	public function get_assumed_site_creation_date() {
1026
		$earliest_registered_users  = get_users(
1027
			array(
1028
				'role'    => 'administrator',
1029
				'orderby' => 'user_registered',
1030
				'order'   => 'ASC',
1031
				'fields'  => array( 'user_registered' ),
1032
				'number'  => 1,
1033
			)
1034
		);
1035
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
1036
1037
		$earliest_posts = get_posts(
1038
			array(
1039
				'posts_per_page' => 1,
1040
				'post_type'      => 'any',
1041
				'post_status'    => 'any',
1042
				'orderby'        => 'date',
1043
				'order'          => 'ASC',
1044
			)
1045
		);
1046
1047
		// If there are no posts at all, we'll count only on user registration date.
1048
		if ( $earliest_posts ) {
1049
			$earliest_post_date = $earliest_posts[0]->post_date;
1050
		} else {
1051
			$earliest_post_date = PHP_INT_MAX;
1052
		}
1053
1054
		return min( $earliest_registration_date, $earliest_post_date );
1055
	}
1056
1057
	/**
1058
	 * Adds the activation source string as a parameter to passed arguments.