WC_Admin_Settings::show_messages PHP Method

show_messages() public static method

Output messages + errors.
public static show_messages ( ) : string
return string
        public static function show_messages()
        {
            if (sizeof(self::$errors) > 0) {
                foreach (self::$errors as $error) {
                    echo '<div id="message" class="error inline"><p><strong>' . esc_html($error) . '</strong></p></div>';
                }
            } elseif (sizeof(self::$messages) > 0) {
                foreach (self::$messages as $message) {
                    echo '<div id="message" class="updated inline"><p><strong>' . esc_html($message) . '</strong></p></div>';
                }
            }
        }

Usage Example

コード例 #1
0
 /**
  * Manage activations
  */
 public function pages()
 {
     // Anything you need to do before a page is loaded
     do_action('woocommerce_grow_pages_start');
     // Get current tab
     $current_tab = empty($_GET['tab']) ? 'dashboard' : sanitize_title($_GET['tab']);
     $this->add_woocommerce_grow_pages();
     // Save settings if data has been posted
     if (!empty($_POST)) {
         $this->save($current_tab);
     }
     // Add any posted messages
     if (!empty($_GET['wc_grow_error'])) {
         WC_Admin_Settings::add_error(stripslashes($_GET['wc_error']));
     }
     if (!empty($_GET['wc_grow_message'])) {
         WC_Admin_Settings::add_message(stripslashes($_GET['wc_message']));
     }
     WC_Admin_Settings::show_messages();
     // Add tabs on the Grow page
     $tabs = apply_filters('woocommerce_grow_page_tabs_array', array());
     include 'views/html-grow-page.php';
 }