function new_duplicated_terms_filter($post_ids, $duplicates_only = true) { global $wpdb, $sitepress, $wpml_admin_notices; require_once ICL_PLUGIN_PATH . '/inc/taxonomy-term-translation/wpml-term-hierarchy-duplication.class.php'; $hier_dupl = new WPML_Term_Hierarchy_Duplication($wpdb, $sitepress); $taxonomies = $hier_dupl->duplicates_require_sync($post_ids, $duplicates_only); if ((bool) $taxonomies) { $text = __('<p>Some taxonomy terms are out of sync between languages. This means that content in some languages will not have the correct tags or categories.</p> <p>In order to synchronize the taxonomies, you need to go over each of them from the following list and click the "Update taxonomy hierarchy" button.</p>', 'wpml-translation-management'); $collapsed = 'Taxonomy sync problem'; foreach ($taxonomies as $taxonomy) { $text .= '<p><a href="admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/taxonomy-translation.php&taxonomy=' . $taxonomy . '&sync=1">' . get_taxonomy_labels(get_taxonomy($taxonomy))->name . '</a></p>'; } $text .= '<p align="right"><a target="_blank" href="https://wpml.org/documentation/getting-started-guide/translating-post-categories-and-custom-taxonomies/#synchronizing-hierarchical-taxonomies">Help about translating taxonomy >></a></p>'; $notice = new WPML_Notice('wpml-taxonomy-hierarchy-sync', $text, 'wpml-core'); $notice->set_css_class_types('info'); $notice->set_collapsed_text($collapsed); $notice->set_hideable(false); $notice->set_dismissible(false); $notice->set_collapsable(true); $wpml_admin_notices->add_notice($notice); } else { remove_taxonomy_hierarchy_message(); } }
/** * @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); } }
/** * @param WPML_Notice $notice * @param string|null $localized_text * * @return string */ private function get_collapsed_html(WPML_Notice $notice, $localized_text = null) { $content = ' <div class="otgs-notice-collapsed-text"> <p>%s <span class="otgs-notice-collapse-show notice-collapse"><span class="screen-reader-text"> %s </span></span> </p> </div> <div class="otgs-notice-collapse-text"> %s </div> '; $content = sprintf($content, $notice->get_collapsed_text(), $localized_text ? esc_html($localized_text) : esc_html__('Show this notice.', 'sitepress'), $notice->get_text()); return $content; }
/** * @param WPML_Notice $notice * * @return bool */ private function notice_exists(WPML_Notice $notice) { $notice_id = $notice->get_id(); $notice_group = $notice->get_group(); return $this->notice_group_and_id_exists($notice_group, $notice_id); }