Making WordPress.org

Changeset 1026


Ignore:
Timestamp:
12/05/2014 01:33:10 PM (10 years ago)
Author:
kovshenin
Message:

WordCamp.org: Add speakers, sessions and sponsors to the At a Glance Dashboard widget.

Fixes #610.
Props hlashbrooke.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/css/admin.css

    r2 r1026  
    66    width: 80px;
    77}
     8#dashboard_right_now a.wcb_speaker-count:before,
     9#dashboard_right_now span.wcb_speaker-count:before {
     10    content: "\f488";
     11}
     12#dashboard_right_now a.wcb_session-count:before,
     13#dashboard_right_now span.wcb_session-count:before {
     14    content: "\f489";
     15}
     16#dashboard_right_now a.wcb_sponsor-count:before,
     17#dashboard_right_now span.wcb_sponsor-count:before {
     18    content: "\f487";
     19}
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    r968 r1026  
    5050        add_filter( 'the_content', array( $this, 'add_speaker_info_to_session_posts' ) );
    5151        add_filter( 'the_content', array( $this, 'add_session_info_to_speaker_posts' ) );
     52
     53        add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ) );
    5254    }
    5355
     
    249251            case 'edit-wcb_sponsor':
    250252            case 'edit-wcb_session':
     253            case 'dashboard':
    251254                wp_enqueue_style( 'wcpt-admin', plugins_url( '/css/admin.css', __FILE__ ), array(), 1 );
    252255                break;
     
    18851888        register_widget( 'WCPT_Widget_Organizers' );
    18861889    }
     1890
     1891    /**
     1892     * Add post types to 'At a Glance' dashboard widget
     1893     */
     1894    function glance_items( $items = array() ) {
     1895        $post_types = array( 'wcb_speaker', 'wcb_session', 'wcb_sponsor' );
     1896
     1897        foreach ( $post_types as $post_type ) {
     1898
     1899            if ( ! post_type_exists( $post_type ) ) {
     1900                continue;
     1901            }
     1902
     1903            $num_posts = wp_count_posts( $post_type );
     1904            $post_type_object = get_post_type_object( $post_type );
     1905
     1906            if ( $num_posts && $num_posts->publish ) {
     1907
     1908                switch ( $post_type ) {
     1909                    case 'wcb_speaker':
     1910                        $text = $text = _n( '%s Speaker', '%s Speakers', $num_posts->publish );
     1911                        break;
     1912                    case 'wcb_session':
     1913                        $text = $text = _n( '%s Session', '%s Sessions', $num_posts->publish );
     1914                        break;
     1915                    case 'wcb_sponsor':
     1916                        $text = $text = _n( '%s Sponsor', '%s Sponsors', $num_posts->publish );
     1917                        break;
     1918                    default:
     1919                }
     1920
     1921                $text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
     1922
     1923                if ( current_user_can( $post_type_object->cap->edit_posts ) ) {
     1924                    $items[] = sprintf( '<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $post_type, $text ) . "\n";
     1925                } else {
     1926                    $items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $post_type, $text ) . "\n";
     1927                }
     1928            }
     1929        }
     1930
     1931        return $items;
     1932    }
    18871933}
    18881934
Note: See TracChangeset for help on using the changeset viewer.