From 4c0d9a6f78145f1bb66202125eac7ba9aa236b3c Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Wed, 25 Nov 2015 10:47:00 +0000 Subject: [PATCH 1/3] Change log: Fix Unreleased comparison link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f709b68..0ba94e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,6 @@ _No changes._ - Initial release. -[unreleased]: https://github.com/GaryJones/Gamajo-Dashboard-Glancer/compare/1.0.0...HEAD +[unreleased]: https://github.com/GaryJones/Gamajo-Dashboard-Glancer/compare/1.0.2...HEAD [1.0.2]: https://github.com/GaryJones/Gamajo-Dashboard-Glancer/compare/1.0.1...1.0.2 [1.0.1]: https://github.com/GaryJones/Gamajo-Dashboard-Glancer/compare/1.0.0...1.0.1 From cc9452d5d79a76eb24c364536df54577d86eab83 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sun, 15 May 2016 22:34:13 +0100 Subject: [PATCH 2/3] Add dashicons support --- class-gamajo-dashboard-glancer.php | 54 +++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/class-gamajo-dashboard-glancer.php b/class-gamajo-dashboard-glancer.php index 04e3e5b..6ea9ba1 100644 --- a/class-gamajo-dashboard-glancer.php +++ b/class-gamajo-dashboard-glancer.php @@ -22,7 +22,7 @@ class Gamajo_Dashboard_Glancer { * * @since 1.0.0 * - * @type array + * @var array */ protected $items; @@ -37,6 +37,7 @@ class Gamajo_Dashboard_Glancer { */ public function __construct() { add_action( 'dashboard_glance_items', array( $this, 'show' ), 20 ); + add_action( 'admin_enqueue_scripts', array( $this, 'dashboard_css' ) ); } /** @@ -55,6 +56,7 @@ public function add( $post_types, $statuses = 'publish' ) { // If relevant output action hook has already passed, then no point in proceeding. if ( did_action( 'dashboard_glance_items' ) ) { _doing_it_wrong( __CLASS__, 'Trying to add At a Glance items to dashboard widget afterhook already fired', '1.0.0' ); + return; } @@ -178,15 +180,17 @@ public function get_link_url( array $item ) { */ protected function maybe_link( $text, $href ) { if ( current_user_can( 'edit_posts' ) ) { - return '' . $text . ''; + return '' . esc_html( $text ) . ''; } - return $text; + return '' . esc_html( $text ) . ''; } /** * Wrap number and text within list item markup. * + * The extra work for populating classes is to provide dashicons support. + * * @since 1.0.0 * * @param string $text Text to display. May be wrapped in a link. @@ -194,6 +198,48 @@ protected function maybe_link( $text, $href ) { * @return string Markup for list item. */ protected function get_markup( $text, $post_type ) { - return '
  • ' . $text . '
  • ' . "\n"; + $class = ''; + $classes[] = $post_type . '-count'; + $post_type_object = get_post_type_object( $post_type ); + $menu_icon = isset( $post_type_object->menu_icon ) ? $post_type_object->menu_icon : null; + + if ( 0 === strpos( $menu_icon, 'dashicons-' ) ) { + $classes[] = 'dashicons-before'; + $classes[] = $menu_icon; + } + + $class = join( ' ', sanitize_html_class( $classes ) ); + + return '
  • ' . wp_kses_post( $text ) . '
  • ' . "\n"; + } + + /** + * Add post types icon styling to Dashboard page. + * + * To override the overly-specific core styles, we apply styles to ignore + * the default circle, and with the classes added to the list item (not + * anchor), get dashicons showing there instead. + * + * @since 1.1.0 + * + * @return null Return early if style already added, or the Dashboard page. + */ + public function dashboard_css() { + static $added_style; + + if ( $added_style ) { + return; + } + + $screen = get_current_screen(); + + if ( ! in_array( $screen->base, array( 'dashboard' ), true ) ) { + return; + } + + // Remove default circle, and style dashicons we add via classes. + echo ''; + + $added_style = true; } } From 3fcb7d8cc7447f42ee7ba98b22d3e552e810042e Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sun, 31 Jul 2016 17:24:56 +0100 Subject: [PATCH 3/3] 1.0.3 --- CHANGELOG.md | 10 ++++++++-- class-gamajo-dashboard-glancer.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ba94e6..64a23fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,15 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased][unreleased] +## [Unreleased] _No changes._ +## [1.0.3] - 2016-07-31 + +- Added support for dashicons. +- Fixed incorrect link in change log. + ## [1.0.2] - 2015-08-12 - Fix regression in 1.0.1 for labels. @@ -20,6 +25,7 @@ _No changes._ - Initial release. -[unreleased]: https://github.com/GaryJones/Gamajo-Dashboard-Glancer/compare/1.0.2...HEAD +[Unreleased]: https://github.com/GaryJones/Gamajo-Dashboard-Glancer/compare/1.0.3...HEAD +[1.0.3]: https://github.com/GaryJones/Gamajo-Dashboard-Glancer/compare/1.0.2...1.0.3 [1.0.2]: https://github.com/GaryJones/Gamajo-Dashboard-Glancer/compare/1.0.1...1.0.2 [1.0.1]: https://github.com/GaryJones/Gamajo-Dashboard-Glancer/compare/1.0.0...1.0.1 diff --git a/class-gamajo-dashboard-glancer.php b/class-gamajo-dashboard-glancer.php index 6ea9ba1..fd79be8 100644 --- a/class-gamajo-dashboard-glancer.php +++ b/class-gamajo-dashboard-glancer.php @@ -7,7 +7,7 @@ * @link http://gamajo.com/dashboard-glancer * @copyright 2013 Gary Jones, Gamajo Tech * @license GPL-2.0+ - * @version 1.0.2 + * @version 1.0.3 */ /**