right_now_content_table_end function not working?

I noticed recently my custom counts for custom post types are not showing on the dashboard. Im using this function:

right_now_content_table_end

Read More

It worked well before, Im not sure when it stopped working but I think after updating to 3.8?

Or is there a new function I should use with the new dashboard that is in 3.8?

Thanks in advance.

Related posts

3 comments

  1. The new action is dashboard_glance_items. It is a filter providing an array to which you can add items.

    Example from my plugin T5 Taxonomy Location

    add_filter(
        'dashboard_glance_items',
        array ( $this, 'add_to_glance' )
    );
    
    
    /**
     * Add locations to the new "At a glance" dashboard widget.
     *
     * @param  array $items
     * @return array
     */
    public function add_to_glance( Array $items )
    {
        $num  = wp_count_terms( $this->taxonomy );
        // Singular or Plural.
        $text = _n(
            '%s Location',
            '%s Locations',
            $num,
            'plugin_t5_tax_location'
        );
        // thousands separator etc.
        $text = sprintf( $text, number_format_i18n( $num ) );
    
        if ( current_user_can( "manage_$this->taxonomy" ) )
        {
            $url  = admin_url( "edit-tags.php?taxonomy=$this->taxonomy" );
            $text = "<a href='$url'>$text</a>";
        }
    
        $items[] = $text;
    
        return $items;
    }
    

    This change is not backwards compatible and rather … dirty. See ticket #26571 for problems and possible solutions.

  2. Please check out this function. I believe it’s temporary solution, but it works for me. More info can be found here: Add Custom Post Types and Taxonomies to At a Glance dashboard widget

    add_action( 'dashboard_glance_items', 'cor_right_now_content_table_end' );
    function cor_right_now_content_table_end() {
    $args = array(
        'public' => true,
        '_builtin' => false
    );
    $output = 'object';
    $operator = 'and';
    
    $post_types = get_post_types( $args, $output, $operator );
    foreach ( $post_types as $post_type ) {
        $num_posts = wp_count_posts( $post_type->name );
        $num = number_format_i18n( $num_posts->publish );
        $text = _n( $post_type->labels->singular_name, $post_type->labels->name, intval( $num_posts->publish ) );
        if ( current_user_can( 'edit_posts' ) ) {
            $output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $num . '&nbsp;' . $text . '</a>';
        }
        echo '<li class="post-count ' . $post_type->name . '-count">' . $output . '</li>';
    }
    $taxonomies = get_taxonomies( $args, $output, $operator );
    foreach ( $taxonomies as $taxonomy ) {
        $num_terms = wp_count_terms( $taxonomy->name );
        $num = number_format_i18n( $num_terms );
        $text = _n( $taxonomy->labels->singular_name, $taxonomy->labels->name, intval( $num_terms ) );
        if ( current_user_can( 'manage_categories' ) ) {
            $output = '<a href="edit-tags.php?taxonomy=' . $taxonomy->name . '">' . $num . '&nbsp;' . $text . '</a>';
        }
        echo '<li class="taxonomy-count ' . $taxonomy->name . '-count">' . $output . '</li>';
    }
    }
    
    // Add Some CSS to "At a Glance" Widget
    function custom_colors() {
    echo '<style type="text/css">
        .slides-count a:before {content:"f233"!important}
        .gallery-count a:before {content:"f163"!important}
        </style>';
    }
    add_action('admin_head', 'custom_colors');
    

Comments are closed.