Changeset 1400
- Timestamp:
- 03/13/2015 11:55:01 PM (11 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012
- Files:
-
- 1 added
- 2 edited
-
functions.php (modified) (2 diffs)
-
shortcode-about-stats.php (added)
-
style.css (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/functions.php
r1144 r1400 43 43 add_filter( 'nav_menu_css_class', array( __CLASS__, 'nav_menu_css_class' ), 10, 3 ); 44 44 add_filter( 'wp_nav_menu_items', array( __CLASS__, 'add_rss_links_to_footer_menu' ), 10, 2 ); 45 46 add_shortcode( 'wcc_about_stats', array( __CLASS__, 'shortcode_about_stats' ) ); 45 47 } 46 48 … … 645 647 return $url; 646 648 } 649 650 /** 651 * Render the [wcc_about_stats] shortcode 652 * 653 * @param array $attributes 654 * 655 * @return string 656 */ 657 public static function shortcode_about_stats( $attributes ) { 658 $map_stats = self::get_map_stats(); 659 660 ob_start(); 661 require( __DIR__ . '/shortcode-about-stats.php' ); 662 return ob_get_clean(); 663 } 664 665 /** 666 * Gather the stats for the [wcc_about_stats] shortcode 667 * 668 * There isn't an easy way to collect the country stats programmatically, but it just takes a minute to 669 * manually count the number countries on the map that have pins. 670 * 671 * @return array 672 */ 673 protected static function get_map_stats() { 674 $transient_key = 'wcc_about_map_stats'; 675 676 if ( ! $map_stats = get_transient( $transient_key ) ) { 677 $cities = array(); 678 $wordcamps = new WP_Query( array( 679 'post_type' => 'wordcamp', 680 'posts_per_page' => -1, 681 ) ); 682 683 // Count the number of cities 684 foreach ( $wordcamps->posts as $wordcamp ) { 685 $url = get_post_meta( $wordcamp->ID, 'URL', true ); 686 687 if ( $hostname = parse_url( $url, PHP_URL_HOST ) ) { 688 $city = explode( '.', $hostname ); 689 $cities[ $city[0] ] = true; 690 } 691 } 692 693 // Compile the results 694 $map_stats = array( 695 'wordcamps' => $wordcamps->found_posts, 696 'cities' => count( $cities ), 697 'countries' => 48, 698 'continents' => 6, 699 ); 700 701 // todo set_transient( $transient_key, $map_stats, 2 * WEEK_IN_DAYS ); 702 } 703 704 return $map_stats; 705 } 647 706 } 648 707 -
sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/style.css
r1113 r1400 1974 1974 } 1975 1975 1976 #content .map-stats p { 1976 #content .about-stats { 1977 margin: 0; 1978 background-color: #f1f6f9; 1979 } 1980 1981 #content .about-stats li { 1977 1982 float: left; 1978 1983 width: 25%; 1979 margin: 0; 1984 margin: 0 -1px 0 0; /* right value matches width of the border, to avoid each element being larger than 25% of the container width */ 1985 padding: 2.75em 0 2em 0; 1986 list-style-type: none; 1987 border-right: 1px solid #e6ebee; 1980 1988 1981 1989 text-align: center; 1982 1990 text-transform: uppercase; 1983 font-size: 12px !important; 1984 font-weight: 600 !important; 1985 1986 color: #969696; 1987 } 1988 1989 #content .map-stats p strong { 1990 color: #424242; 1991 1992 color: #82878a; 1993 } 1994 1995 #content .about-stats li:last-child { 1996 border-right: none; 1997 } 1998 1999 .about-stat-number { 2000 display: block; 2001 margin-bottom: 10px; 2002 color: #7b8083; 1991 2003 font-family: adelle, "Georgia", serif; 1992 font-size: 38px; 2004 font-size: 50px; 2005 font-weight: bold; 2006 } 2007 2008 .about-stat-descriptor { 2009 display: block; 2010 font-size: 18px; 2011 letter-spacing: 1px; 1993 2012 } 1994 2013 … … 3221 3240 width: 100%; 3222 3241 } 3242 3243 #content .about-stats li { 3244 float: none; 3245 width: auto; 3246 border-left: none; 3247 border-bottom: 1px solid #E6EBEE; 3248 } 3249 #content .about-stats li:last-child { 3250 border-bottom: none; 3251 } 3223 3252 } 3224 3253
Note: See TracChangeset
for help on using the changeset viewer.