Completed
Push — add/handling-connection-errors ( 700587...612b6c )
by
unknown
06:53
created

Invalid_Blog_Token::admin_notice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * The Jetpack Connection error handler class for invalid blog tokens
4
 *
5
 * @package automattic/jetpack-connection
6
 */
7
8
namespace Automattic\Jetpack\Connection\Error_Handlers;
9
10
/**
11
 * This class handles all the error codes that indicates a broken blog token and
12
 * suggests the user to reconnect.
13
 */
14
class Invalid_Blog_Token {
15
16
	/**
17
	 * Set up hooks
18
	 *
19
	 * @param array $errors The array containing verified errors stored in the database.
20
	 */
21
	public function __construct( $errors ) {
22
23
		// In this class, we will only handle errors with the blog token, so ignoring if there are only errors with user tokens.
24
		if ( ! isset( $errors[0] ) || ! isset( $errors['invalid'] ) ) {
25
			add_action( 'jetpack_notices', array( $this, 'admin_notice' ) );
26
		}
27
28
	}
29
30
	/**
31
	 * Prints an admin notice for the blog token error
32
	 *
33
	 * @return void
34
	 */
35
	public function admin_notice() {
36
		?>
37
		<div class="notice notice-error is-dismissible jetpack-message jp-connect" style="display:block !important;">
38
			<p><?php esc_html_e( 'Your connection with WordPress.com seems to be broken. If you\'re experiencing issues, please try to reconnect.', 'jetpack' ); ?></p>
39
		</div>
40
		<?php
41
	}
42
43
44
}
45