Skip to content

Commit

Permalink
updatees display of admin notices
Browse files Browse the repository at this point in the history
  • Loading branch information
kasprzyk-sz committed Oct 31, 2024
1 parent ebfdf27 commit 80ff22d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion wp-content/plugins/embl-taxonomy/assets/embl-taxonomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ document.addEventListener('DOMContentLoaded', function() {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('filter') && urlParams.get('filter') === 'deprecated') {
// Change button text and URL
showDeprecatedButton.textContent = 'View All Terms';
showDeprecatedButton.textContent = 'See all taxonomy terms';
showDeprecatedButton.setAttribute('data-href', `${emblTaxonomySettings.adminUrl}edit-tags.php?taxonomy=${emblTaxonomySettings.taxonomyName}`);
}

Expand Down
32 changes: 19 additions & 13 deletions wp-content/plugins/embl-taxonomy/includes/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,20 +714,20 @@ public function action_admin_notices() {
}

// Sync happened (all pages)
if (($now - $modified) <= 10) {
printf('<div class="%1$s"><p>%2$s</p></div>',
esc_attr('notice notice-success'),
esc_html(sprintf(
__('%1$s was recently synced.', 'embl'),
$this->labels['name']
))
);
$notice = true;
}
// if (($now - $modified) <= 10) {
// printf('<div class="%1$s"><p>%2$s</p></div>',
// esc_attr('notice notice-success'),
// esc_html(sprintf(
// __('%1$s was recently synced.', 'embl'),
// $this->labels['name']
// ))
// );
// $notice = true;
// }

// Manual sync notice (edit taxonomy page only)
if ( current_user_can( 'administrator' ) ) {
if ( ! $notice && function_exists('get_current_screen')) {
if ( function_exists('get_current_screen')) {
$screen = get_current_screen();
if ($screen->id === 'edit-embl_taxonomy') {
if (isset($_GET['synced']) && $_GET['synced'] === 'true') {
Expand Down Expand Up @@ -757,7 +757,13 @@ public function action_admin_notices() {
$deprecated_count = $this->get_deprecated_terms_count(); // Assume this function returns count of deprecated terms
if ( function_exists('get_current_screen')) {
$screen = get_current_screen();
if ($screen->id === 'edit-embl_taxonomy') {
if ($screen->id === 'edit-embl_taxonomy') {
if (isset($_GET['delete-deprecated']) && $_GET['delete-deprecated'] === 'true') {
printf('<div class="%1$s"><p>%2$s</p></div>',
esc_attr('notice notice-success'),
__('Deprecated terms have been deleted.', 'embl')
);
}
if ($deprecated_count > 0) {
printf('<div class="%1$s"><p><span>%2$s</span> %3$s %4$s</p></div>',
esc_attr('notice notice-warning'),
Expand All @@ -768,7 +774,7 @@ public function action_admin_notices() {
sprintf(
'<button id="embl-taxonomy-show-deprecated" type="button" data-href="%1$s" class="button button-small">%2$s</button>',
esc_attr('edit-tags.php?taxonomy=' . EMBL_Taxonomy::TAXONOMY_NAME . '&filter=deprecated'),
esc_html(__('View all deprecated terms', 'embl'))
esc_html(__('See all deprecated terms', 'embl'))
),
sprintf(
'<button id="embl-taxonomy-delete-deprecated" type="button" data-href="%1$s" class="button button-small" style="color: #fff; border-color: #d41645; background: #d41645;">%2$s</button>',
Expand Down

0 comments on commit 80ff22d

Please sign in to comment.