Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryJones committed May 20, 2018
2 parents aca9d8a + 3b0479e commit 9e6d0bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A class to copy into your WordPress plugin, to make adding custom post type counts to the _At a Glance_ dashboard widget considerably easier.

[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/GaryJones/Gamajo-Dashboard-Glancer/badges/quality-score.png?s=543e04781b27f58b1e37ba742f760c0c5ba82297)](https://scrutinizer-ci.com/g/GaryJones/Gamajo-Dashboard-Glancer/)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/gamajo/dashboard-glancer/badges/quality-score.png?s=543e04781b27f58b1e37ba742f760c0c5ba82297)](https://scrutinizer-ci.com/g/gamajo/dashboard-glancer/)

## Description

Expand Down
19 changes: 11 additions & 8 deletions class-gamajo-dashboard-glancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @link https://github.com/gamajo/dashboard-glancer
* @copyright 2013 Gary Jones, Gamajo
* @license GPL-2.0-or-later
* @version 1.0.4
* @version 1.0.5
*/

/**
Expand Down Expand Up @@ -52,7 +52,11 @@ public function __construct() {
* @return null Return early if action hook has already passed, or no valid
* post types were given.
*/
public function add( $post_types, $statuses = 'publish' ) {
public function add( $post_types, $statuses = null ) {
if ( null === $statuses ) {
$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' );
Expand Down Expand Up @@ -102,7 +106,7 @@ public function show() {
protected function unset_invalid_post_types( array $post_types ) {
foreach ( $post_types as $index => $post_type ) {
$post_type_object = get_post_type_object( $post_type );
if ( is_null( $post_type_object ) ) {
if ( null === $post_type_object ) {
unset( $post_types[ $index ] );
}
}
Expand Down Expand Up @@ -198,17 +202,16 @@ protected function maybe_link( $text, $href ) {
* @return string Markup for list item.
*/
protected function get_markup( $text, $post_type ) {
$class = '';
$classes[] = $post_type . '-count';
$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;
$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 ) );
$class = implode( ' ', sanitize_html_class( $classes ) );

return '<li class="' . esc_attr( $class ) . '">' . wp_kses_post( $text ) . '</li>' . "\n";
}
Expand All @@ -233,7 +236,7 @@ public function dashboard_css() {

$screen = get_current_screen();

if ( ! in_array( $screen->base, array( 'dashboard' ), true ) ) {
if ( 'dashboard' !== $screen->base ) {
return;
}

Expand Down

0 comments on commit 9e6d0bb

Please sign in to comment.