Changeset 3814
- Timestamp:
- 08/16/2016 04:28:32 PM (9 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt
- Files:
-
- 24 added
- 1 deleted
- 1 edited
-
applications/tracker.php (modified) (6 diffs)
-
javascript/tracker (added)
-
javascript/tracker/build (added)
-
javascript/tracker/build/tracker.min.css (added)
-
javascript/tracker/build/tracker.min.js (added)
-
javascript/tracker/source (added)
-
javascript/tracker/source/components (added)
-
javascript/tracker/source/components/filterable-table (added)
-
javascript/tracker/source/components/filterable-table/filterable-table.jsx (added)
-
javascript/tracker/source/components/filterable-table/header-cell.jsx (added)
-
javascript/tracker/source/components/filterable-table/header.jsx (added)
-
javascript/tracker/source/components/filterable-table/row.jsx (added)
-
javascript/tracker/source/components/filterable-table/style.scss (added)
-
javascript/tracker/source/components/filterable-table/table.jsx (added)
-
javascript/tracker/source/components/search-field (added)
-
javascript/tracker/source/components/search-field/search-field.jsx (added)
-
javascript/tracker/source/components/sorting-indicator (added)
-
javascript/tracker/source/components/sorting-indicator/sorting-indicator.jsx (added)
-
javascript/tracker/source/components/sorting-indicator/style.scss (added)
-
javascript/tracker/source/stores (added)
-
javascript/tracker/source/stores/table-store.js (added)
-
javascript/tracker/source/style.scss (added)
-
javascript/tracker/source/tracker.jsx (added)
-
package.json (added)
-
views/applications/tracker/shortcode-application-tracker.php (deleted)
-
webpack.config.js (added)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/applications/tracker.php
r2910 r3814 2 2 3 3 namespace WordPress_Community\Applications\Tracker; 4 use \WordCamp_Loader; 4 5 defined( 'WPINC' ) or die(); 5 6 6 7 const SHORTCODE_SLUG = 'application-tracker'; 7 8 8 add_shortcode( SHORTCODE_SLUG, __NAMESPACE__ . '\render_status_shortcode' );9 add_action( 'wp_ print_styles', __NAMESPACE__ . '\print_shortcode_styles');9 add_shortcode( SHORTCODE_SLUG, __NAMESPACE__ . '\render_status_shortcode' ); 10 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' ); 10 11 11 12 /** … … 13 14 */ 14 15 function render_status_shortcode() { 15 $statuses = \WordCamp_Loader::get_post_statuses(); 16 $milestones = \WordCamp_Loader::map_statuses_to_milestones(); 17 $posts = get_active_wordcamps( $statuses ); 18 19 ob_start(); 20 21 require_once( dirname( __DIR__ ) . '/wcpt-wordcamp/wordcamp-admin.php' ); 22 require( dirname( __DIR__ ) . '/views/applications/tracker/shortcode-application-tracker.php' ); 23 24 return ob_get_clean(); 16 return '<div id="wpc-application-tracker">Loading Application Tracker...</div>'; 25 17 } 26 18 … … 28 20 * Get camps that are active enough to be shown on the tracker 29 21 * 30 * @param array $statuses31 *32 22 * @return array 33 23 */ 34 function get_active_wordcamps( $statuses ) { 24 function get_active_wordcamps() { 25 $wordcamps = array(); 26 $statuses = WordCamp_Loader::get_post_statuses(); 27 $milestones = WordCamp_Loader::map_statuses_to_milestones(); 35 28 $inactive_timestamp = strtotime( '60 days ago' ); 36 29 … … 39 32 $shown_statuses = array_keys( $shown_statuses ); 40 33 41 $ wordcamps = get_posts( array(34 $raw_posts = get_posts( array( 42 35 'post_type' => WCPT_POST_TYPE_ID, 43 36 'post_status' => $shown_statuses, … … 47 40 ) ); 48 41 49 foreach ( $ wordcamps as $key => $wordcamp) {50 $ wordcamp->last_update_timestamp = get_last_update_timestamp( $wordcamp->ID );42 foreach ( $raw_posts as $key => $post ) { 43 $last_update_timestamp = get_last_update_timestamp( $post->ID ); 51 44 52 if ( $ wordcamp->last_update_timestamp <= $inactive_timestamp ) {53 unset( $wordcamps[ $key ] );45 if ( $last_update_timestamp <= $inactive_timestamp ) { 46 continue; 54 47 } 55 48 56 $wordcamp->url = filter_var( get_post_meta( $wordcamp->ID, 'URL', true ), FILTER_VALIDATE_URL ); 49 $wordcamps[] = array( 50 'city' => $post->post_title, 51 'cityUrl' => filter_var( get_post_meta( $post->ID, 'URL', true ), FILTER_VALIDATE_URL ), 52 'applicant' => get_post_meta( $post->ID, 'Organizer Name', true ), 53 'milestone' => $milestones[ $post->post_status ], 54 'status' => $statuses[ $post->post_status ], 55 'lastUpdate' => human_time_diff( time(), $last_update_timestamp ) . ' ago', 56 ); 57 57 } 58 58 … … 80 80 81 81 /** 82 * Print CSS styles for the [application-tracker] shortcode.82 * Enqueue scripts and styles 83 83 */ 84 function print_shortcode_styles() {84 function enqueue_scripts() { 85 85 global $post; 86 86 87 if ( empty( $post->post_content ) || ! has_shortcode( $post->post_content, SHORTCODE_SLUG ) ) { 87 wp_register_script( 88 'wpc-application-tracker', 89 plugins_url( 'javascript/tracker/build/tracker.min.js', dirname( __FILE__ ) ), 90 array(), 91 1, 92 true 93 ); 94 95 wp_register_style( 96 'wpc-application-tracker', 97 plugins_url( 'javascript/tracker/build/tracker.min.css', dirname( __FILE__ ) ), 98 array( 'dashicons', 'list-tables' ), 99 1 100 ); 101 102 if ( ! is_a( $post, 'WP_POST' ) || ! has_shortcode( $post->post_content, SHORTCODE_SLUG ) ) { 88 103 return; 89 104 } 90 91 ?>92 105 93 <style type="text/css"> 94 .application-tracker.striped > tbody > :nth-child( odd ) { 95 background-color: #f9f9f9; 96 } 106 wp_enqueue_script( 'wpc-application-tracker' ); 97 107 98 /* Show extra data on large screens */ 99 .application-tracker .milestone, 100 .application-tracker .applicant { 101 display: none; 102 } 108 wp_localize_script( 109 'wpc-application-tracker', 110 'wpcApplicationTracker', 111 array( 112 'applications' => get_active_wordcamps(), 113 'displayColumns' => get_display_columns(), 114 'initialSortField' => 'city', 115 ) 116 ); 103 117 104 @media screen and ( min-width: 750px ) { 105 .application-tracker .applicant { 106 display: table-cell; 107 } 108 } 118 wp_enqueue_style( 'wpc-application-tracker' ); 119 } 109 120 110 @media screen and ( min-width: 850px ) { 111 .application-tracker .milestone { 112 display: table-cell; 113 } 114 } 115 </style> 116 117 <?php 121 /** 122 * Get the columns headers 123 * 124 * @return array 125 */ 126 function get_display_columns() { 127 return array( 128 'city' => 'City', 129 'applicant' => 'Applicant', 130 'milestone' => 'Milestone', 131 'status' => 'Status', 132 'lastUpdate' => 'Updated', 133 ); 118 134 }
Note: See TracChangeset
for help on using the changeset viewer.