Changeset 1585410
- Timestamp:
- 01/30/2017 11:07:47 PM (9 years ago)
- File:
-
- 1 edited
-
interserve-data-feed/trunk/Data/Statistics.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
interserve-data-feed/trunk/Data/Statistics.php
r1015750 r1585410 81 81 * @return string html 82 82 */ 83 public function renderShortcode() 84 { 85 $data = $this->getData(); 86 if (empty($data)) { 87 return '<p class="isdata_statistics">No data available</p>'; 83 public function renderShortcode($args='') 84 { 85 global $wpdb; // ick! wordpress global variable 86 87 $newdata = $this->getData(); 88 89 if (empty($newdata)) { 90 return '0'; 91 } 92 if($args!='') { 93 if($args['name']=='Job Count') { 94 $subQuery = 'SELECT count(ID) jobcount FROM '.$wpdb->posts.' WHERE post_type = "isdata_job"'; 95 $result = $wpdb->get_results($subQuery); 96 $output = $result[0]->jobcount; 97 } elseif($args['name']=='Story Count') { 98 $subQuery = 'SELECT count(ID) storycount FROM '.$wpdb->posts.' WHERE post_type = "isdata_story"'; 99 $result = $wpdb->get_results($subQuery); 100 $output = $result[0]->storycount; 101 } elseif($args['name']=='Profession Count') { 102 $terms = get_terms('isdata_profession', array('hide_empty' => false)); 103 $output = count($terms); 104 } elseif($args['name']=='Location Count') { 105 $terms = get_terms('isdata_location', array('hide_empty' => false)); 106 $output = count($terms); 107 } else { 108 foreach ($newdata as $title => $value) { 109 if(strtolower($args['name'])==strtolower($title)) { 110 $output .= esc_html($value); 111 break; 112 } 113 } 114 } 115 } else { 116 $output = '<dl class="isdata_statistics">'; 117 foreach ($newdata as $title => $value) { 118 if ($title == 'Updated') { 119 continue; 120 } 121 $output .= '<dt>' . esc_html($title) . '</dt><dd>' . esc_html($value) . '</dd>'; 122 } 123 $output .= '</dl>'; 88 124 } 89 90 $output = '<dl class="isdata_statistics">';91 foreach ($data as $title => $value) {92 if ($title == 'Updated') {93 continue;94 }95 $output .= '<dt>' . esc_html($title) . '</dt><dd>' . esc_html($value) . '</dd>';96 }97 $output .= '</dl>';98 125 return $output; 99 126 }
Note: See TracChangeset
for help on using the changeset viewer.