Changeset 3357952
- Timestamp:
- 09/08/2025 01:44:21 PM (7 months ago)
- Location:
- easy-dashboard
- Files:
-
- 4 edited
- 1 copied
-
tags/1.6 (copied) (copied from easy-dashboard/trunk)
-
tags/1.6/easy-dashboard.php (modified) (9 diffs)
-
tags/1.6/readme.txt (modified) (2 diffs)
-
trunk/easy-dashboard.php (modified) (9 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easy-dashboard/tags/1.6/easy-dashboard.php
r3308406 r3357952 2 2 /** 3 3 * Plugin Name: Easy Dashboard 4 * Plugin URI: https://w pgov.it4 * Plugin URI: https://www.marcomilesi.com 5 5 * Description: Refresh your WordPress dashboard with this new elegant, metro-based one. 6 6 * Author: Marco Milesi 7 7 * Author URI: https://marcomilesi.com 8 * Version: 1. 58 * Version: 1.6 9 9 * License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 10 10 * Text Domain: easy-dashboard … … 101 101 return; 102 102 } 103 103 // Ensure Dashicons are available on our custom admin page 104 wp_enqueue_style('dashicons'); 105 104 106 wp_enqueue_style( 105 107 self::SLUG . '-admin', … … 108 110 self::VERSION 109 111 ); 110 112 111 113 // Inline styles as fallback if CSS file doesn't exist 112 114 $this->add_inline_styles(); … … 227 229 color: ' . $colors['primary'] . '; 228 230 transition: color 0.3s ease; 231 display: inline-block; 232 } 233 234 /* Image icons (when a menu item provides an image URL) */ 235 img.<a href="http://playground.local/wp-admin/admin.php?page=telegram_main" class="easy-dashboard-box small"> 236 <img src="" class="easy-dashboard-icon" alt="Telegram"> 237 <p class="easy-dashboard-label">Telegram</p> 238 </a> { 239 max-width: 48px; 240 max-height: 48px; 241 width: 48px; 242 height: 48px; 243 display: block; 244 margin: 0 auto 15px; 245 object-fit: contain; 229 246 } 230 247 … … 248 265 .easy-dashboard-box.small .easy-dashboard-icon { 249 266 font-size: 32px !important; 267 margin-bottom: 10px; 268 } 269 270 .easy-dashboard-box.small img.easy-dashboard-icon { 271 width: 32px; 272 height: 32px; 250 273 margin-bottom: 10px; 251 274 } … … 375 398 } 376 399 '; 377 wp_add_inline_style('wp-admin', $css); 400 // Attach our inline styles to the plugin stylesheet handle so they reliably load 401 wp_add_inline_style(self::SLUG . '-admin', $css); 378 402 } 379 403 … … 485 509 private function render_menu_box($menu_item, $is_small = false) { 486 510 $url = $this->format_menu_link($menu_item[2]); 487 $ icon_class = isset($menu_item[6]) ? $menu_item[6] : 'dashicons-admin-generic';511 $raw_icon = isset($menu_item[6]) ? $menu_item[6] : ''; 488 512 $label = $this->get_menu_label($menu_item); 489 513 $size_class = $is_small ? ' small' : ''; 490 514 515 // Use the WP Dashboard dashicon as the default fallback for missing icons 516 $dashicon_class = 'dashicons-dashboard'; 517 518 if (is_string($raw_icon) && $raw_icon !== '') { 519 // Try to find a dashicons class in the string 520 if (preg_match('/(dashicons[-_\w]+)/', $raw_icon, $m)) { 521 $dashicon_class = $m[1]; 522 } else { 523 // Treat the raw value as a possible class name (clean it) 524 $clean = preg_replace('/[^A-Za-z0-9_\- ]+/', '', $raw_icon); 525 if (trim($clean) !== '') { 526 $dashicon_class = trim($clean); 527 } 528 } 529 } 530 531 // Check if dashicon_class contains data:image base64 and reset to dashboard icon 532 if (strpos($dashicon_class, 'base64') !== false) { 533 $dashicon_class = 'dashicons-dashboard'; 534 } 535 536 // Always use dashicons class 491 537 printf( 492 538 '<a href="%s" class="easy-dashboard-box%s"> 493 <div class="dashicons easy-dashboard-icon %s" ></div>539 <div class="dashicons easy-dashboard-icon %s" aria-hidden="true"></div> 494 540 <p class="easy-dashboard-label">%s</p> 495 541 </a>', 496 542 esc_url(admin_url($url)), 497 543 esc_attr($size_class), 498 esc_attr($ icon_class),544 esc_attr($dashicon_class), 499 545 esc_html($label) 500 546 ); … … 505 551 */ 506 552 private function get_menu_label($menu_item) { 507 // Only show "Commenti" for Comments and "Plugin" for Plugins508 553 $slug = $menu_item[2]; 509 if ($slug === 'edit-comments.php' || $slug === 'plugins.php') { 510 // Use only the first word (usually the menu title) 511 $label = wp_strip_all_tags($menu_item[0]); 512 // Remove anything after the first space or parenthesis 513 $label = preg_replace('/[\s\(].*$/', '', $label); 514 return $label; 515 } 516 517 if ($this->is_custom_post_type_menu($menu_item[2])) { 518 $post_type = $this->get_post_type_from_slug($menu_item[2]); 554 555 // Keep friendly fixed labels for Comments and Plugins 556 if ($slug === 'edit-comments.php') { 557 return __('Comments', 'easy-dashboard'); 558 } 559 560 if ($slug === 'plugins.php') { 561 return __('Plugins', 'easy-dashboard'); 562 } 563 564 // For custom post types, prefer the post type's plural name 565 if ($this->is_custom_post_type_menu($slug)) { 566 $post_type = $this->get_post_type_from_slug($slug); 519 567 $post_type_object = get_post_type_object($post_type); 520 568 … … 524 572 } 525 573 526 return wp_strip_all_tags($menu_item[0]); 574 // Default: strip tags and remove notification counts/trailing numbers 575 $label = wp_strip_all_tags($menu_item[0]); 576 577 // Remove patterns like "11 notifications" or "11 notification" (case-insensitive) 578 $label = preg_replace('/\s*\d+\s*notifications?$/i', '', $label); 579 580 // Remove any trailing number left (e.g. "Yoast SEO 11") 581 $label = preg_replace('/\s*\d+$/', '', $label); 582 583 // Trim whitespace and return 584 return trim($label); 527 585 } 528 586 -
easy-dashboard/tags/1.6/readme.txt
r3308406 r3357952 4 4 Requires at least: 3.6 5 5 Tested up to: 6.9 6 Version: 1. 57 Stable tag: 1. 56 Version: 1.6 7 Stable tag: 1.6 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 32 32 33 33 == Changelog == 34 35 = 1.6 2025-09-08 = 36 * Improved code and performance 34 37 35 38 = 1.5 2025-06-09 = -
easy-dashboard/trunk/easy-dashboard.php
r3308406 r3357952 2 2 /** 3 3 * Plugin Name: Easy Dashboard 4 * Plugin URI: https://w pgov.it4 * Plugin URI: https://www.marcomilesi.com 5 5 * Description: Refresh your WordPress dashboard with this new elegant, metro-based one. 6 6 * Author: Marco Milesi 7 7 * Author URI: https://marcomilesi.com 8 * Version: 1. 58 * Version: 1.6 9 9 * License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 10 10 * Text Domain: easy-dashboard … … 101 101 return; 102 102 } 103 103 // Ensure Dashicons are available on our custom admin page 104 wp_enqueue_style('dashicons'); 105 104 106 wp_enqueue_style( 105 107 self::SLUG . '-admin', … … 108 110 self::VERSION 109 111 ); 110 112 111 113 // Inline styles as fallback if CSS file doesn't exist 112 114 $this->add_inline_styles(); … … 227 229 color: ' . $colors['primary'] . '; 228 230 transition: color 0.3s ease; 231 display: inline-block; 232 } 233 234 /* Image icons (when a menu item provides an image URL) */ 235 img.<a href="http://playground.local/wp-admin/admin.php?page=telegram_main" class="easy-dashboard-box small"> 236 <img src="" class="easy-dashboard-icon" alt="Telegram"> 237 <p class="easy-dashboard-label">Telegram</p> 238 </a> { 239 max-width: 48px; 240 max-height: 48px; 241 width: 48px; 242 height: 48px; 243 display: block; 244 margin: 0 auto 15px; 245 object-fit: contain; 229 246 } 230 247 … … 248 265 .easy-dashboard-box.small .easy-dashboard-icon { 249 266 font-size: 32px !important; 267 margin-bottom: 10px; 268 } 269 270 .easy-dashboard-box.small img.easy-dashboard-icon { 271 width: 32px; 272 height: 32px; 250 273 margin-bottom: 10px; 251 274 } … … 375 398 } 376 399 '; 377 wp_add_inline_style('wp-admin', $css); 400 // Attach our inline styles to the plugin stylesheet handle so they reliably load 401 wp_add_inline_style(self::SLUG . '-admin', $css); 378 402 } 379 403 … … 485 509 private function render_menu_box($menu_item, $is_small = false) { 486 510 $url = $this->format_menu_link($menu_item[2]); 487 $ icon_class = isset($menu_item[6]) ? $menu_item[6] : 'dashicons-admin-generic';511 $raw_icon = isset($menu_item[6]) ? $menu_item[6] : ''; 488 512 $label = $this->get_menu_label($menu_item); 489 513 $size_class = $is_small ? ' small' : ''; 490 514 515 // Use the WP Dashboard dashicon as the default fallback for missing icons 516 $dashicon_class = 'dashicons-dashboard'; 517 518 if (is_string($raw_icon) && $raw_icon !== '') { 519 // Try to find a dashicons class in the string 520 if (preg_match('/(dashicons[-_\w]+)/', $raw_icon, $m)) { 521 $dashicon_class = $m[1]; 522 } else { 523 // Treat the raw value as a possible class name (clean it) 524 $clean = preg_replace('/[^A-Za-z0-9_\- ]+/', '', $raw_icon); 525 if (trim($clean) !== '') { 526 $dashicon_class = trim($clean); 527 } 528 } 529 } 530 531 // Check if dashicon_class contains data:image base64 and reset to dashboard icon 532 if (strpos($dashicon_class, 'base64') !== false) { 533 $dashicon_class = 'dashicons-dashboard'; 534 } 535 536 // Always use dashicons class 491 537 printf( 492 538 '<a href="%s" class="easy-dashboard-box%s"> 493 <div class="dashicons easy-dashboard-icon %s" ></div>539 <div class="dashicons easy-dashboard-icon %s" aria-hidden="true"></div> 494 540 <p class="easy-dashboard-label">%s</p> 495 541 </a>', 496 542 esc_url(admin_url($url)), 497 543 esc_attr($size_class), 498 esc_attr($ icon_class),544 esc_attr($dashicon_class), 499 545 esc_html($label) 500 546 ); … … 505 551 */ 506 552 private function get_menu_label($menu_item) { 507 // Only show "Commenti" for Comments and "Plugin" for Plugins508 553 $slug = $menu_item[2]; 509 if ($slug === 'edit-comments.php' || $slug === 'plugins.php') { 510 // Use only the first word (usually the menu title) 511 $label = wp_strip_all_tags($menu_item[0]); 512 // Remove anything after the first space or parenthesis 513 $label = preg_replace('/[\s\(].*$/', '', $label); 514 return $label; 515 } 516 517 if ($this->is_custom_post_type_menu($menu_item[2])) { 518 $post_type = $this->get_post_type_from_slug($menu_item[2]); 554 555 // Keep friendly fixed labels for Comments and Plugins 556 if ($slug === 'edit-comments.php') { 557 return __('Comments', 'easy-dashboard'); 558 } 559 560 if ($slug === 'plugins.php') { 561 return __('Plugins', 'easy-dashboard'); 562 } 563 564 // For custom post types, prefer the post type's plural name 565 if ($this->is_custom_post_type_menu($slug)) { 566 $post_type = $this->get_post_type_from_slug($slug); 519 567 $post_type_object = get_post_type_object($post_type); 520 568 … … 524 572 } 525 573 526 return wp_strip_all_tags($menu_item[0]); 574 // Default: strip tags and remove notification counts/trailing numbers 575 $label = wp_strip_all_tags($menu_item[0]); 576 577 // Remove patterns like "11 notifications" or "11 notification" (case-insensitive) 578 $label = preg_replace('/\s*\d+\s*notifications?$/i', '', $label); 579 580 // Remove any trailing number left (e.g. "Yoast SEO 11") 581 $label = preg_replace('/\s*\d+$/', '', $label); 582 583 // Trim whitespace and return 584 return trim($label); 527 585 } 528 586 -
easy-dashboard/trunk/readme.txt
r3308406 r3357952 4 4 Requires at least: 3.6 5 5 Tested up to: 6.9 6 Version: 1. 57 Stable tag: 1. 56 Version: 1.6 7 Stable tag: 1.6 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 32 32 33 33 == Changelog == 34 35 = 1.6 2025-09-08 = 36 * Improved code and performance 34 37 35 38 = 1.5 2025-06-09 =
Note: See TracChangeset
for help on using the changeset viewer.