README.md
62 lines
| 1 | # Usage Examples |
| 2 | ## Minimum requirement |
| 3 | ``` |
| 4 | <?php |
| 5 | require_once 'recommended-plugins-notice/notice.php'; |
| 6 | |
| 7 | do_action( |
| 8 | 'wpmudev-recommended-plugins-register-notice', |
| 9 | plugin_basename(__FILE__), // Plugin basename |
| 10 | 'My Plugin Name', // Plugin Name |
| 11 | array( |
| 12 | 'top_level_page_screen_id' // Screen IDs |
| 13 | ), |
| 14 | ); |
| 15 | ``` |
| 16 | |
| 17 | # Development Mode |
| 18 | ## Always ON |
| 19 | This code below will always show the notice on every page. |
| 20 | ``` |
| 21 | <?php |
| 22 | require_once 'recommended-plugins-notice/notice.php'; |
| 23 | |
| 24 | add_filter( 'wpmudev-recommended-plugins-is-displayable', '__return_true' ); |
| 25 | add_filter( |
| 26 | 'wpmudev-recommended-plugin-active-registered', |
| 27 | function () { |
| 28 | $active = new WPMUDEV_Recommended_Plugins_Notice_Registered_Plugin( 'basename' ); |
| 29 | $active->selector = array( 'after', '.sui-wrap .sui-header' ); |
| 30 | $active->name = 'Sample'; |
| 31 | |
| 32 | return $active; |
| 33 | } |
| 34 | ); |
| 35 | ``` |
| 36 | ## Custom time trigger |
| 37 | Default of notice to be displayed in plugin page(s) is **14** days after its registered. |
| 38 | You can decrease or even increase this because why not. |
| 39 | ``` |
| 40 | <?php |
| 41 | add_filter( |
| 42 | 'wpmudev-recommended-plugins-notice-display-seconds-after-registered', |
| 43 | function ( $time_trigger ) { |
| 44 | // 1 minute trigger |
| 45 | $time_trigger = 1 * MINUTE_IN_SECONDS; |
| 46 | |
| 47 | return $time_trigger; |
| 48 | } |
| 49 | ); |
| 50 | ``` |
| 51 | ## Un-dismiss |
| 52 | Accidentally or purposed-ly dismiss the notice for whatever reason ? this below code can undo that. |
| 53 | ``` |
| 54 | <?php |
| 55 | add_action( |
| 56 | 'wpmudev-recommended-plugins-before-display', |
| 57 | function () { |
| 58 | WPMUDEV_Recommended_Plugins_Notice::get_instance()->un_dismiss(); |
| 59 | } |
| 60 | ); |
| 61 | ``` |
| 62 |