Metro_Sitemap::show_action_message PHP Method

show_action_message() public static method

Displays a notice, error or warning to the user
public static show_action_message ( str $message, $level = 'notice' )
$message str The message to show to the user
    public static function show_action_message($message, $level = 'notice')
    {
        $class = 'updated';
        if ($level === 'warning') {
            $class = 'update-nag';
        } elseif ($level === 'error') {
            $class = 'error';
        }
        echo '<div class="' . esc_attr($class) . ' msm-sitemap-message"><p>' . wp_kses($message, wp_kses_allowed_html('post')) . '</p></div>';
    }

Usage Example

 /**
  * Resets sitemap data and prints out a message to the user.
  *
  * Hooked into the msm_sitemap_actions-reset_sitemap_data action.
  */
 public static function action_reset_data()
 {
     // Do the same as when we finish then tell use to delete manuallyrather than remove all data
     self::reset_sitemap_data();
     Metro_Sitemap::show_action_message(sprintf(__('<p>Sitemap data reset. If you want to completely remove the data you must do so manually by deleting all posts with post type <code>%1$s</code>.</p><p>The WP-CLI command to do this is: <code>%2$s</code></p>', 'msm-sitemap'), Metro_Sitemap::SITEMAP_CPT, 'wp post delete $(wp post list --post_type=' . Metro_Sitemap::SITEMAP_CPT . ' --format=ids)'));
 }