Skip to content

Commit a7e8181

Browse files
authored
Merge pull request #3 from norcross/fix/dismiss-admin-notice
updating admin notice function
2 parents 2b97d07 + 08582fd commit a7e8181

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

comment-blacklist-manager.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private function __construct() {
4444
add_action ( 'admin_init', array( $this, 'update_blacklist_admin' ) );
4545
add_action ( 'admin_init', array( $this, 'update_blacklist_manual' ) );
4646
add_action ( 'admin_notices', array( $this, 'manual_update_notice' ) );
47-
47+
add_filter ( 'removable_query_args', array( $this, 'add_removable_args' ) );
4848
register_activation_hook ( __FILE__, array( $this, 'run_initial_process' ) );
4949
register_deactivation_hook ( __FILE__, array( $this, 'remove_settings' ) );
5050
}
@@ -164,7 +164,7 @@ public function source_field() {
164164
// loop through the sources and display a list with icon to view
165165
foreach( (array) $sources as $source ) {
166166

167-
echo '<li><a class="imgedit-help-toggle" href="' . esc_url( $source ) . '" title="' . __( 'View external source', 'comment-blacklist-manager' ) . '" target="_blank"><span class="dashicons dashicons-external"></span></a>&nbsp;' . esc_url( $source ) . '</li>';
167+
echo '<li class="widefat"><a href="' . esc_url( $source ) . '" title="' . __( 'View external source', 'comment-blacklist-manager' ) . '" target="_blank"><span class="dashicons dashicons-external"></span></a>&nbsp;' . esc_url( $source ) . '</li>';
168168

169169
}
170170

@@ -260,7 +260,7 @@ public function update_blacklist_manual() {
260260
self::blacklist_process_loader();
261261

262262
// set a query string to redirect to
263-
$redirect = admin_url( 'options-discussion.php' ) . '?cblm-update=success';
263+
$redirect = add_query_arg( array( 'cblm-update' => 'success' ), admin_url( 'options-discussion.php' ) );
264264

265265
wp_redirect( $redirect );
266266
exit();
@@ -275,16 +275,32 @@ public function update_blacklist_manual() {
275275
public function manual_update_notice() {
276276

277277
// check for our query string
278-
if ( ! isset( $_REQUEST['cblm-update'] ) || isset( $_REQUEST['cblm-update'] ) && $_REQUEST['cblm-update'] !== 'success' ) {
278+
if ( ! isset( $_GET['cblm-update'] ) || sanitize_text_field( $_GET['cblm-update'] ) !== 'success' ) {
279279
return;
280280
}
281281

282-
echo '<div id="setting-error-settings_updated" class="updated settings-error">';
282+
// Output the actual markup for the message.
283+
echo '<div class="notice notice-success is-dismissible">';
283284
echo '<p><strong>' . __( 'Blacklist terms were updated successfully.', 'comment-blacklist-manager' ) . '</strong></p>';
284285
echo '</div>';
285286

286287
}
287288

289+
/**
290+
* Add our custom strings to the vars.
291+
*
292+
* @param array $args The existing array of args.
293+
*
294+
* @return array $args The modified array of args.
295+
*/
296+
public function add_removable_args( $args ) {
297+
298+
// Set the default args, passing along a filter.
299+
$set_removable_args = apply_filters( 'cblm_removable_args', array( 'cblm-update' ) );
300+
301+
// Include my new args and return.
302+
return wp_parse_args( $set_removable_args, $args );
303+
}
288304

289305
/**
290306
* our actual updating function. is done in 3 parts

0 commit comments

Comments
 (0)