public function add_action(WPML_Notice_Action $action)
 {
     $this->actions[] = $action;
     if ($action->can_dismiss()) {
         $this->dismissible = true;
     }
     if ($action->can_hide()) {
         $this->hideable = true;
     }
 }
 /**
  * @param string $type
  * @param string $action
  * @param string $plugin_or_theme
  */
 private function add_notice($type, $action, $plugin_or_theme)
 {
     $message = '';
     if ('install' === $action) {
         if ('plugin' === $type) {
             $message = __('Do you want to scan for translatable strings in the plugin(s)?', 'wpml-string-translation');
         }
         if ('theme' === $type) {
             $message = __('Do you want to scan for translatable strings in the theme?', 'wpml-string-translation');
         }
     }
     if ('update' === $action && ('plugin' === $type || 'theme' === $type)) {
         $message = __('Do you want to scan for new translatable strings?', 'wpml-string-translation');
     }
     $url_args = array($type => $plugin_or_theme);
     $url_hash = '';
     if ('theme' === $type) {
         $url_hash = 'icl_strings_in_theme_wrap';
     }
     if ($message) {
         $string_scan_page = ICL_PLUGIN_FOLDER . '/menu/theme-localization.php';
         $url = admin_url('admin.php?page=' . $string_scan_page);
         $url = add_query_arg($url_args, $url);
         if ($url_hash) {
             $url .= '#' . $url_hash;
         }
         $themes_and_plugins_settings = new WPML_ST_Themes_And_Plugins_Settings();
         $notice = new WPML_Notice($plugin_or_theme, '<strong>' . $plugin_or_theme . '</strong>&nbsp;&mdash;&nbsp;' . $message, $themes_and_plugins_settings->get_notices_group());
         $notice->set_css_class_types('info');
         $notice->set_exclude_from_pages(array($string_scan_page));
         $notice->add_action(new WPML_Notice_Action(__('Scan now', 'wpml-string-translation'), $url, false, false, true));
         $notice->add_action(new WPML_Notice_Action(__('Skip', 'wpml-string-translation'), '#', false, true));
         $dismiss_all_action = new WPML_Notice_Action(__('Dismiss all these notices', 'wpml-string-translation'), '#', false, false, false);
         $dismiss_all_action->set_group_to_dismiss($this->settings->get_notices_group());
         $dismiss_all_action->set_js_callback('wpml_st_hide_strings_scan_notices');
         $notice->add_action($dismiss_all_action);
         $this->admin_notices->add_notice($notice);
     }
 }
 /**
  * @param WPML_Notice_Action $action
  *
  * @return string
  */
 private function get_action_anchor(WPML_Notice_Action $action)
 {
     $action_url = '<a href="' . esc_url_raw($action->get_url()) . '"';
     $action_url_classes = array('notice-action');
     if ($action->must_display_as_button()) {
         $button_style = 'button-secondary';
         if (is_string($action->must_display_as_button())) {
             $button_style = $action->must_display_as_button();
         }
         $action_url_classes[] = esc_attr($button_style);
         $action_url_classes[] = 'notice-action-' . esc_attr($button_style);
     } else {
         $action_url_classes[] = 'notice-action-link';
     }
     $action_url .= ' class="' . implode(' ', $action_url_classes) . '"';
     if ($action->get_group_to_dismiss()) {
         $action_url .= ' data-dismiss-group="' . esc_attr($action->get_group_to_dismiss()) . '"';
         $action_url .= ' data-nonce="' . wp_create_nonce('otgs-hide-notice-for-group') . '"';
     }
     if ($action->get_js_callback()) {
         $action_url .= ' data-js-callback="' . esc_attr($action->get_js_callback()) . '"';
     }
     $action_url .= '>';
     $action_url .= $action->get_text();
     $action_url .= '</a>';
     return $action_url;
 }