Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Last active January 1, 2016 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GaryJones/8133765 to your computer and use it in GitHub Desktop.
Save GaryJones/8133765 to your computer and use it in GitHub Desktop.
Usage examples for Gamajo_Dashboard_Glancer
<?php
// 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' );
}
// 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
}
<?php
// 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' );
require plugin_dir_path( 'includes/class-gamajo-dashboard-rightnow.php' );
}
// WP 3.8 and later
add_action( 'dashboard_glance_items', 'prefix_add_dashboard_counts' );
function prefix_add_dashboard_counts() {
$post_types = array( 'mp_ingredient', 'mp_recipe', 'mp_mealplan' );
$statuses = array( 'publish', 'draft' );
$glancer = new Gamajo_Dashboard_Glancer;
$glancer->add( $post_types, $statuses );
}
// WP 3.7 and earlier
add_action( 'right_now_content_table_end', 'prefix_add_dashboard_counts_old' );
function prefix_add_dashboard_counts_old() {
$post_types = array( 'mp_ingredient', 'mp_recipe', 'mp_mealplan' );
$statuses = array( 'publish', 'draft' );
$glancer = new Gamajo_Dashboard_RightNow;
$glancer->add( $post_types, $statuses );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment