[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * bbPress Forum Content Statistics Functions 4 * 5 * @package bbPress 6 */ 7 8 9 10 /** 11 * Get the total number of forums 12 * 13 * @since 1.0 14 * @uses $bbdb Database Object 15 * @uses $bb_total_forums Cache of result generated by previous run 16 * 17 * @return int 18 */ 19 function get_total_forums() { 20 global $bbdb, $bb_total_forums; 21 if ( isset($bb_total_forums) ) 22 return $bb_total_forums; 23 $bb_total_forums = $bbdb->get_var("SELECT COUNT(*) FROM $bbdb->forums USE INDEX (PRIMARY)"); 24 return $bb_total_forums; 25 } 26 27 /** 28 * Output the number of forums 29 * 30 * @since 1.0 31 */ 32 function total_forums() { 33 echo apply_filters('total_forums', get_total_forums() ); 34 } 35 36 /** 37 * Get the total number of users 38 * 39 * @since 1.0 40 * @uses $bbdb Database Object 41 * @uses $bb_total_users Cache of result generated by previous run 42 * 43 * @return int 44 */ 45 function bb_get_total_users() 46 { 47 global $bbdb, $bb_total_users; 48 if ( isset( $bb_total_users ) ) { 49 return $bb_total_users; 50 } 51 if ( false === $bb_total_users = apply_filters( 'bb_get_total_users', false ) ) { 52 $bb_total_users = $bbdb->get_var( "SELECT COUNT(*) FROM $bbdb->users USE INDEX (PRIMARY);" ); 53 } 54 return $bb_total_users; 55 } 56 57 /** 58 * Output the number of users 59 * 60 * @since 1.0 61 */ 62 function bb_total_users() 63 { 64 echo apply_filters( 'total_users', bb_get_total_users() ); 65 } 66 67 /** 68 * Get the total number of posts 69 * 70 * @since 0.7.2 71 * @uses $bbdb Database Object 72 * @uses $bb_total_posts Cache of result generated by previous run 73 * 74 * @return int 75 */ 76 function get_total_posts() { 77 global $bbdb, $bb_total_posts; 78 if ( isset($bb_total_posts) ) 79 return $bb_total_posts; 80 $bb_total_posts = $bbdb->get_var("SELECT SUM(posts) FROM $bbdb->forums"); 81 return $bb_total_posts; 82 } 83 84 /** 85 * Output the number of posts 86 * 87 * @since 0.7.2 88 */ 89 function total_posts() { 90 echo apply_filters('total_posts', get_total_posts() ); 91 } 92 93 /** 94 * Get the total number of topics 95 * 96 * @since 0.7.2 97 * @uses $bbdb Database Object 98 * @uses $bb_total_topics Cache of result generated by previous run 99 * 100 * @return int 101 */ 102 function get_total_topics() { 103 global $bbdb, $bb_total_topics; 104 if ( isset($bb_total_topics) ) 105 return $bb_total_topics; 106 $bb_total_topics = $bbdb->get_var("SELECT SUM(topics) FROM $bbdb->forums"); 107 return $bb_total_topics; 108 } 109 110 /** 111 * Output the number of topics 112 * 113 * @since 0.7.2 114 */ 115 function total_topics() { 116 echo apply_filters('total_topics', get_total_topics()); 117 } 118 119 /** 120 * Get the popular topics 121 * 122 * @since 0.7.2 123 * 124 * @param int $num Number of topics to return 125 * @return array 126 */ 127 function get_popular_topics( $num = 10 ) { 128 $query = new BB_Query( 'topic', array('per_page' => $num, 'order_by' => 'topic_posts', 'append_meta' => 0) ); 129 return $query->results; 130 } 131 132 /** 133 * Output the date when current installation was created 134 * 135 * @since 0.8 136 * 137 * @param string|array $args Arguments to pass through to bb_get_inception() 138 */ 139 function bb_inception( $args = '' ) { 140 $args = _bb_parse_time_function_args( $args ); 141 $time = apply_filters( 'bb_inception', bb_get_inception( array('format' => 'mysql') + $args), $args ); 142 echo _bb_time_function_return( $time, $args ); 143 } 144 145 /** 146 * Get the date when current installation was created 147 * 148 * @since 0.8 149 * @uses $bbdb Database Object 150 * @uses $bb_inception Result cache 151 * 152 * @param string|array $args Formatting options for the timestamp. 153 * @return int 154 */ 155 function bb_get_inception( $args = '' ) { 156 $args = _bb_parse_time_function_args( $args ); 157 158 global $bbdb, $bb_inception; 159 if ( !isset($bb_inception) ) 160 $bb_inception = $bbdb->get_var("SELECT topic_start_time FROM $bbdb->topics ORDER BY topic_start_time LIMIT 1"); 161 162 return apply_filters( 'bb_get_inception', _bb_time_function_return( $bb_inception, $args ) ); 163 } 164 165 /** 166 * Get the average number of registrations per day 167 * 168 * @since 0.7.2 169 * 170 * @return int|float 171 */ 172 function get_registrations_per_day() 173 { 174 return bb_get_total_users() / ceil( ( time() - bb_get_inception( 'timestamp' ) ) / 3600 / 24 ); 175 } 176 177 /** 178 * Output the average number of registrations per day 179 * 180 * @since 0.7.2 181 */ 182 function registrations_per_day() { 183 echo apply_filters('registrations_per_day', bb_number_format_i18n(get_registrations_per_day(),3)); 184 } 185 186 /** 187 * Get the average number of posts per day 188 * 189 * @since 0.7.2 190 * 191 * @return int|float 192 */ 193 function get_posts_per_day() { 194 return get_total_posts() / ceil( ( time() - bb_get_inception( 'timestamp' ) ) / 3600 / 24 ); 195 } 196 197 /** 198 * Output the average number of posts per day 199 * 200 * @since 0.7.2 201 */ 202 function posts_per_day() { 203 echo apply_filters('posts_per_day', bb_number_format_i18n(get_posts_per_day(),3)); 204 } 205 206 /** 207 * Get the average number of topics per day 208 * 209 * @since 0.7.2 210 * 211 * @return int|float 212 */ 213 function get_topics_per_day() { 214 return get_total_topics() / ceil( ( time() - bb_get_inception( 'timestamp' ) ) / 3600 / 24 ); 215 } 216 217 /** 218 * Output the average number of topics per day 219 * 220 * @since 0.7.2 221 */ 222 function topics_per_day() { 223 echo apply_filters('topics_per_day', bb_number_format_i18n(get_topics_per_day(),3)); 224 } 225 226 function bb_get_total_topic_tags() 227 { 228 global $bb_total_topic_tags; 229 if ( isset($bb_total_topic_tags) ) { 230 return $bb_total_topic_tags; 231 } 232 global $wp_taxonomy_object; 233 $bb_total_topic_tags = $wp_taxonomy_object->count_terms( 'bb_topic_tag' ); 234 return $bb_total_topic_tags; 235 } 236 237 function bb_total_topic_tags() 238 { 239 echo apply_filters( 'bb_total_topic_tags', bb_get_total_topic_tags() ); 240 } 241 242 function bb_get_topic_tags_per_day() 243 { 244 return bb_get_total_topic_tags() / ceil( ( time() - bb_get_inception( 'timestamp' ) ) / 3600 / 24 ); 245 } 246 247 function bb_topic_tags_per_day() 248 { 249 echo apply_filters('bb_topic_tags_per_day', bb_number_format_i18n( bb_get_topic_tags_per_day(), 3 ) ); 250 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 7 01:01:35 2017 | Cross-referenced by PHPXref 0.7.1 |