Code Duplication    Length = 11-13 lines in 4 locations

modules/sso.php 1 location

@@ 604-616 (lines=13) @@
601
		return $xml->getResponse();
602
	}
603
604
	static function request_initial_nonce() {
605
		Jetpack::load_xml_rpc_client();
606
		$xml = new Jetpack_IXR_Client( array(
607
			'user_id' => get_current_user_id(),
608
		) );
609
		$xml->query( 'jetpack.sso.requestNonce' );
610
611
		if ( $xml->isError() ) {
612
			return new WP_Error( $xml->getErrorCode(), $xml->getErrorMessage() );
613
		}
614
615
		return $xml->getResponse();
616
	}
617
618
	/**
619
	 * The function that actually handles the login!

modules/monitor.php 3 locations

@@ 106-116 (lines=11) @@
103
		<?php
104
	}
105
106
	public function is_active() {
107
		Jetpack::load_xml_rpc_client();
108
		$xml = new Jetpack_IXR_Client( array(
109
			'user_id' => get_current_user_id()
110
		) );
111
		$xml->query( 'jetpack.monitor.isActive' );
112
		if ( $xml->isError() ) {
113
			wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) );
114
		}
115
		return $xml->getResponse();
116
	}
117
118
	/**
119
	 * Tells jetpack.wordpress.com how current user wants to be notified by
@@ 175-187 (lines=13) @@
172
		return $xml->getResponse();
173
	}
174
175
	public function activate_monitor() {
176
		Jetpack::load_xml_rpc_client();
177
		$xml = new Jetpack_IXR_Client( array(
178
			'user_id' => get_current_user_id()
179
		) );
180
181
		$xml->query( 'jetpack.monitor.activate' );
182
183
		if ( $xml->isError() ) {
184
			wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) );
185
		}
186
		return true;
187
	}
188
189
	public function deactivate_monitor() {
190
		Jetpack::load_xml_rpc_client();
@@ 189-201 (lines=13) @@
186
		return true;
187
	}
188
189
	public function deactivate_monitor() {
190
		Jetpack::load_xml_rpc_client();
191
		$xml = new Jetpack_IXR_Client( array(
192
			'user_id' => get_current_user_id()
193
		) );
194
195
		$xml->query( 'jetpack.monitor.deactivate' );
196
197
		if ( $xml->isError() ) {
198
			wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) );
199
		}
200
		return true;
201
	}
202
203
	/*
204
	 * Returns date of the last downtime.