/** * @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> — ' . $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); } }