PHPackages                             gamajo/dashboard-glancer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gamajo/dashboard-glancer

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

gamajo/dashboard-glancer
========================

A class for your WordPress plugin, to make adding custom post type counts to the At a Glance dashboard widget considerably easier.

1.0.5(8y ago)45467[1 issues](https://github.com/gamajo/dashboard-glancer/issues)GPL-2.0-or-laterPHPPHP &gt;=5.2.4

Since Jan 16Pushed 8y ago3 watchersCompare

[ Source](https://github.com/gamajo/dashboard-glancer)[ Packagist](https://packagist.org/packages/gamajo/dashboard-glancer)[ Docs](https://github.com/GaryJones/Gamajo-Dashboard-Glancer)[ RSS](/packages/gamajo-dashboard-glancer/feed)WikiDiscussions develop Synced yesterday

READMEChangelog (6)DependenciesVersions (4)Used By (0)

Gamajo Dashboard Glancer
========================

[](#gamajo-dashboard-glancer)

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://camo.githubusercontent.com/1e50ca164453b82d68b7ddbc2883f056dfeb4a7198a7add8e0e54f5322a9c60c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f67616d616a6f2f64617368626f6172642d676c616e6365722f6261646765732f7175616c6974792d73636f72652e706e673f733d35343365303437383162323766353862316533376261373432663736306330633562613832323937)](https://scrutinizer-ci.com/g/gamajo/dashboard-glancer/)

Description
-----------

[](#description)

WordPress 3.8 introduced the *At a Glance* dashboard widget, as a replacement for the *Right Now* widget. The new widget contains an action hook, `dashboard_glance_items`, which allows developers to insert extra list items into the widget. Although grabbing the number of entries of a certain post type, and maybe a specific status within that post type, and displaying within markup is not tricky, it can't be done as minimally as what this class allows. Add in the desire for wanting to include counts for multiple post types, or multiple statuses, and this class comes into its own. See the Usage section for how simple the code is.

Installation
------------

[](#installation)

This isn't a WordPress plugin on its own, so the usual instructions don't apply. Instead:

### Manually install class

[](#manually-install-class)

1. Copy [`class-gamajo-dashboard-glancer.php`](class-gamajo-dashboard-glancer.php) into your plugin. It can be into a file in the plugin root, or better, an `includes` directory.
2. Ensure the class file is available to whichever code will be using it.

```
// Require the new class (change to your correct path)
if ( ! class_exists( 'Gamajo_Dashboard_Glancer' ) ) {
    require plugin_dir_path( 'includes/class-gamajo-dashboard-glancer.php' );
}
```

or:

### Install class via Composer

[](#install-class-via-composer)

1. Tell Composer to install this class as a dependency: `composer require gamajo/dashboard-glancer`
2. Recommended: Install the Mozart package: `composer require coenjacobs/mozart --dev` and [configure it](https://github.com/coenjacobs/mozart#configuration).
3. The class is now renamed to use your own prefix, to prevent collisions with other plugins bundling this class.

Usage
-----

[](#usage)

Within your plugin files, either as a function, or as part of a class, implement something like:

```
// Hook into the widget (or any hook before it!) to register your items.
add_action( 'dashboard_glance_items', 'prefix_add_dashboard_counts' );
function prefix_add_dashboard_counts() {
    $glancer = new Gamajo_Dashboard_Glancer;
    $glancer->add( 'my_cpt' ); // show only published "my-cpt" entries
}
```

That's it!

### More Usage Examples

[](#more-usage-examples)

```
// Lots of examples of how to add given here, you only need one for each combination of
// multiple post types and multiple statuses.
add_action( 'dashboard_glance_items', 'prefix_add_dashboard_counts' );
function prefix_add_dashboard_counts() {
    $glancer = new Gamajo_Dashboard_Glancer;
    $glancer->add( 'my_cpt' ); // show only published "my-cpt" entries
    $glancer->add( 'my_cpt', 'draft' ); // show only draft "my-cpt" entries
    $glancer->add( 'my_cpt', array( 'publish', 'draft' ) ); // show only published and draft "my-cpt" entries

    // Show only published and draft entries for all three post types
    $my_post_types = array( 'ingredients', 'recipes', 'meal_plan' );
    $glancer->add( $my_post_types, array( 'publish', 'draft' ) );

    // Supports custom statuses as well
    $my_statuses = array( 'pitch', 'assigned', 'in-progress', 'needs-edit', 'ready-to-publish' );
    $glancer->add( 'post', $my_statuses );
}
```

Remember, that code above shows lots of examples of how you can add multiple post types and multiple statuses in one go. For the simplest case, you would instantiate the class, and do a single call to the `add()` method and that's it.

Notes
-----

[](#notes)

The textual label is taken from the custom post type registration itself. It will use the singular label (e.g. *Story*) if the count is exactly 1, or the plural name (e.g. *Stories*) otherwise. If the status is not `publish`, then it will append the status to disambiguate. If the item count is zero, then nothing will show up, to keep visual clutter to a minimum.

The class will automatically output any items still registered, at priority 20 of the `dashboard_glance_items` action hook. If you want to output at an earlier priority, then just call the `show()` method on the object that has the items registered, when hooked in to that earlier priority (here, 8):

```
add_action( 'dashboard_glance_items', 'prefix_add_dashboard_counts', 8 );
function prefix_add_dashboard_counts() {
    $glancer = new Gamajo_Dashboard_Glancer;
    $glancer->add( 'my_cpt' ); // show only published "my-cpt" entries
    $glancer->show();
}
```

Once `show()` is called, all registered items become unregistered, so that `show()` being called again (at priority 20, or manually) will not result in duplicate items showing on the widget.

The class is not a singleton, so if you add items in one function, but want to show early in another, you'll need to pass the object across, likely via a global variable. As a non-singleton, you could also register some items to show early, and some to show late, by instantiating two objects from the `Gamajo_Dashboard_Glancer` class, but only explicitly calling `show()` on one of them.

Backwards Compatibility for WP 3.7 Right Now Widget
---------------------------------------------------

[](#backwards-compatibility-for-wp-37-right-now-widget)

This project also includes the [`Gamajo_Dashboard_RightNow`](class-gamajo-dashboard-widget-rightnow.php) class which is an extension of the main `Gamajo_Dashboard_Glancer` class. This can be instantiated and added to within a function hooked to the `right_now_content_table_end` hook, to provide the same information in the WordPress 3.7 Right Now widget.

```
// Hook into the widget (or any hook before it!) to register your items.
add_action( 'right_now_content_table_end', 'prefix_add_dashboard_counts_old' );
function prefix_add_dashboard_counts_old() {
    $glancer = new Gamajo_Dashboard_RightNow;
    $glancer->add( 'my_cpt' ); // show only published "my-cpt" entries
}
```

Contributions
-------------

[](#contributions)

Contributions are welcome - fork, fix and send pull requests against the `develop` branch please.

License
-------

[](#license)

GPL-2.0+, so feel free to use in any WordPress project. Let me know when you do (not a requirement of usage) as I'd love to know where my code is being used!

Credits
-------

[](#credits)

Built by [Gary Jones](https://twitter.com/GaryJ)
Copyright 2013 Gary Jones, [Gamajo Tech](http://gamajo.com/)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 89.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~123 days

Total

2

Last Release

2963d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba7751eebec0f74a4963e9a062f49e58222b97872bf193d95f0505f3df321d09?d=identicon)[GaryJones](/maintainers/GaryJones)

---

Top Contributors

[![GaryJones](https://avatars.githubusercontent.com/u/88371?v=4)](https://github.com/GaryJones "GaryJones (34 commits)")[![devinsays](https://avatars.githubusercontent.com/u/431879?v=4)](https://github.com/devinsays "devinsays (2 commits)")[![grappler](https://avatars.githubusercontent.com/u/1785641?v=4)](https://github.com/grappler "grappler (1 commits)")[![mundschenk-at](https://avatars.githubusercontent.com/u/6943905?v=4)](https://github.com/mundschenk-at "mundschenk-at (1 commits)")

---

Tags

gamajo-dashboard-glancerglance-dashboard-widgetwordpresswordpress-pluginwordpresstemplates

### Embed Badge

![Health badge](/badges/gamajo-dashboard-glancer/health.svg)

```
[![Health](https://phpackages.com/badges/gamajo-dashboard-glancer/health.svg)](https://phpackages.com/packages/gamajo-dashboard-glancer)
```

###  Alternatives

[aristath/kirki

Extending the WordPress customizer

1.3k73.1k4](/packages/aristath-kirki)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.7k](/packages/afragen-git-updater)[tacowordpress/tacowordpress

WordPress custom post types that feel like CRUD models

232.2k](/packages/tacowordpress-tacowordpress)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
