Skip to content

Commit e209514

Browse files
authored
Merge pull request #37 from OnTheGoSystems/master
Prevent duplicate notices
2 parents 192a294 + e28c596 commit e209514

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/presenters/Whip_WPMessagePresenter.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ class Whip_WPMessagePresenter implements Whip_MessagePresenter {
1414
*/
1515
public function __construct( Whip_Message $message ) {
1616
$this->message = $message;
17-
}
17+
}
1818

19-
/**
19+
/**
2020
* Registers hooks to WordPress. This is a separate function so you can
2121
* control when the hooks are registered.
2222
*/
2323
public function register_hooks() {
24-
add_action( 'admin_notices', array( $this, 'renderMessage' ) );
24+
global $whip_admin_notices_added;
25+
if ( null === $whip_admin_notices_added || ! $whip_admin_notices_added ) {
26+
add_action( 'admin_notices', array( $this, 'renderMessage' ) );
27+
$whip_admin_notices_added = true;
28+
}
2529
}
2630

2731
/**

0 commit comments

Comments
 (0)