← All changes
|
classes/external/php/persist-admin-notices-dismissal/README.md
+11
-2
2.4.1
→
trunk
View file →
| @@ -41,9 +41,9 @@ | ||
| 41 | 41 | function sample_admin_notice__success() { |
| 42 | 42 | if ( ! PAnD::is_admin_notice_active( 'disable-done-notice-forever' ) ) { |
| 43 | 43 | return; |
| 44 | 44 | } |
| 45 | - | |
| 45 | + | |
| 46 | 46 | ?> |
| 47 | 47 | <div data-dismissible="disable-done-notice-forever" class="updated notice notice-success is-dismissible"> |
| 48 | 48 | <p><?php _e( 'Done!', 'sample-text-domain' ); ?></p> |
| 49 | 49 | </div> |
| @@ -60,9 +60,9 @@ | ||
| 60 | 60 | |
| 61 | 61 | ```php |
| 62 | 62 | add_action( 'admin_init', array( 'PAnD', 'init' ) ); |
| 63 | 63 | ``` |
| 64 | - | |
| 64 | + | |
| 65 | 65 | #### Usage Instructions and Examples |
| 66 | 66 | If you have two notices displayed when certain actions are triggered; firstly, choose a string to uniquely identify them, e.g. `notice-one` and `notice-two` |
| 67 | 67 | |
| 68 | 68 | To make the first notice never appear once dismissed, its `data-dismissible` attribute will be `data-dismissible="notice-one-forever"` where `notice-one` is its unique identifier and `forever` is the dismissal time period. |
| @@ -103,6 +103,15 @@ | ||
| 103 | 103 | add_action( 'admin_notices', 'sample_admin_notice__success1' ); |
| 104 | 104 | add_action( 'admin_notices', 'sample_admin_notice__success2' ); |
| 105 | 105 | ``` |
| 106 | 106 | |
| 107 | +You should be a good developer and add the following to your `uninstall.php` file so that we can clean up after ourselves and not leave unnecessary stuff in the options table. | |
| 108 | + | |
| 109 | +```php | |
| 110 | +global $wpdb; | |
| 111 | +$table = is_multisite() ? $wpdb->base_prefix . 'sitemeta' : $wpdb->base_prefix . 'options'; | |
| 112 | +$column = is_multisite() ? 'meta_key' : 'option_name'; | |
| 113 | +$delete_string = 'DELETE FROM ' . $table . ' WHERE ' . $column . ' LIKE %s LIMIT 1000'; | |
| 114 | +$wpdb->query( $wpdb->prepare( $delete_string, array( '%pand-%' ) ) ); | |
| 115 | +``` | |
| 107 | 116 | |
| 108 | 117 | Cool beans. Isn't it? |