Skip to content

Commit cd5c7d5

Browse files
consistent formatting
1 parent 0b88fd7 commit cd5c7d5

File tree

3 files changed

+61
-55
lines changed

3 files changed

+61
-55
lines changed

posts-and-users-stats.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ function posts_and_users_stats_show_users() {
156156
* @return string the file name
157157
*/
158158
function posts_and_users_stats_get_export_file_name( $name ) {
159-
return str_replace( ' ', '-', get_bloginfo( 'name' ) . '-' . $name )
160-
. '-' . date( 'Y-m-d-H-i-s' );
159+
return str_replace( ' ', '-', get_bloginfo( 'name' ) . '-' . $name ) . '-' . date( 'Y-m-d-H-i-s' );
161160
}
162161

163162
/**

views/posts.php

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
3333
</h2>
3434

3535
<?php if ( $selected_tab == 'date' ) {
36-
global $wpdb;
37-
3836
// Get the selected post type.
3937
if ( isset( $_POST['type'] ) && in_array( $_POST['type'], $post_types ) ) {
4038
$selected_post_type = $_POST['type'];
@@ -53,22 +51,29 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
5351
$selected_post_type_name = $selected_post_type_object->label;
5452
}
5553

54+
global $wpdb;
5655
$posts_per_date = $wpdb->get_results(
5756
"SELECT DATE(post_date) as date, count(ID) as count
5857
FROM {$wpdb->posts}
5958
WHERE post_status = 'publish'" . $post_type_query .
60-
"GROUP BY date", OBJECT_K);
59+
"GROUP BY date",
60+
OBJECT_K
61+
);
6162
$posts_per_month = $wpdb->get_results(
6263
"SELECT DATE_FORMAT(post_date, '%Y-%m') as month, count(ID) as count
6364
FROM {$wpdb->posts}
6465
WHERE post_status = 'publish'" . $post_type_query .
65-
"GROUP BY month", OBJECT_K);
66+
"GROUP BY month",
67+
OBJECT_K
68+
);
6669
$posts_per_year = $wpdb->get_results(
6770
"SELECT YEAR(post_date) as year, count(ID) as count
6871
FROM {$wpdb->posts}
6972
WHERE post_status = 'publish'". $post_type_query .
7073
"GROUP BY year
71-
ORDER BY year DESC", OBJECT_K);
74+
ORDER BY year DESC",
75+
OBJECT_K
76+
);
7277

7378
$per_date_string = sprintf( __( '%s per Date', 'posts-and-users-stats' ), $selected_post_type_name );
7479
$per_month_string = sprintf( __( '%s per Month', 'posts-and-users-stats' ), $selected_post_type_name );
@@ -87,7 +92,7 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
8792
</form>
8893
<nav>
8994
<?php if ( !is_array( $posts_per_date ) || sizeof( $posts_per_date ) <= 0) { ?>
90-
<p><?php echo $selected_post_type_labels->not_found ?>
95+
<p><?php echo $selected_post_type_labels->not_found; ?>
9196
<?php } else { ?>
9297
<ul>
9398
<li><a href="#monthly"><?php echo $per_month_string; ?></a>
@@ -131,14 +136,14 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
131136
series: [ {
132137
name: '<?php _e( 'Posts', 'posts-and-users-stats' ); ?>',
133138
data: [ <?php foreach( $posts_per_month as $posts_of_month ) {
134-
$date = strtotime( $posts_of_month->month . '-01' );
135-
$year = date( 'Y', $date );
136-
$month = date( 'm', $date );
137-
echo '[Date.UTC(' . $year . ',' . ( $month - 1 ) . ',1),' . $posts_of_month->count . '], ';
138-
}?> ]
139+
$date = strtotime( $posts_of_month->month . '-01' );
140+
$year = date( 'Y', $date );
141+
$month = date( 'm', $date );
142+
echo '[Date.UTC(' . $year . ',' . ( $month - 1 ) . ',1),' . $posts_of_month->count . '], ';
143+
} ?> ]
139144
} ],
140145
credits: {
141-
enabled: false
146+
enabled: false
142147
},
143148
exporting: {
144149
filename: '<?php echo posts_and_users_stats_get_export_file_name( $per_month_string ); ?>'
@@ -185,12 +190,12 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
185190
series: [ {
186191
name: '<?php _e( 'Posts', 'posts-and-users-stats' ); ?>',
187192
data: [ <?php foreach( $posts_per_date as $posts_of_date ) {
188-
$date = strtotime( $posts_of_date->date );
189-
$year = date( 'Y', $date );
190-
$month = date( 'm', $date );
191-
$day = date( 'd', $date );
192-
echo '[Date.UTC(' . $year . ',' . ( $month - 1 ) . ',' . $day .'),' . $posts_of_date->count . '], ';
193-
}?> ]
193+
$date = strtotime( $posts_of_date->date );
194+
$year = date( 'Y', $date );
195+
$month = date( 'm', $date );
196+
$day = date( 'd', $date );
197+
echo '[Date.UTC(' . $year . ',' . ( $month - 1 ) . ',' . $day .'),' . $posts_of_date->count . '], ';
198+
} ?> ]
194199
} ],
195200
credits: {
196201
enabled: false
@@ -225,8 +230,8 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
225230
<?php foreach( range( 1, 12, 1) as $month ) { ?>
226231
<td class="number"><?php
227232
$date = date('Y-m', strtotime( $year . '-' . $month . '-1' ) );
228-
if ( array_key_exists( $date, $posts_per_month) ) {
229-
posts_and_users_stats_echo_link( get_month_link( $year, $month ), $posts_per_month[$date]->count );
233+
if ( array_key_exists( $date, $posts_per_month ) ) {
234+
posts_and_users_stats_echo_link( get_month_link( $year, $month ), $posts_per_month[ $date ]->count );
230235
} else {
231236
echo 0;
232237
} ?></td>
@@ -264,7 +269,7 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
264269
if ( checkdate( $month, $day, $year ) ) {
265270
$date = date('Y-m-d', strtotime( $year . '-' . $month . '-' . $day ) );
266271
if ( array_key_exists( $date, $posts_per_date ) ) {
267-
posts_and_users_stats_echo_link( get_day_link( $year, $month, $day ), $posts_per_date[$date]->count );
272+
posts_and_users_stats_echo_link( get_day_link( $year, $month, $day ), $posts_per_date[ $date ]->count );
268273
} else {
269274
echo 0;
270275
}
@@ -279,8 +284,8 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
279284
<?php foreach( range( 1, 12, 1) as $month ) { ?>
280285
<td class="number"><strong><?php
281286
$date = date('Y-m', strtotime( $year . '-' . $month . '-1' ) );
282-
if ( array_key_exists( $date, $posts_per_month) ) {
283-
posts_and_users_stats_echo_link( get_month_link( $year, $month ), $posts_per_month[$date]->count );
287+
if ( array_key_exists( $date, $posts_per_month ) ) {
288+
posts_and_users_stats_echo_link( get_month_link( $year, $month ), $posts_per_month[ $date ]->count );
284289
} else {
285290
echo 0;
286291
} ?></strong></td>
@@ -333,7 +338,7 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
333338
categories: [
334339
<?php foreach( $terms as $term ) {
335340
echo "'" . $term->name. "',";
336-
}?> ],
341+
} ?> ],
337342
},
338343
yAxis: {
339344
title: {
@@ -347,8 +352,8 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
347352
series: [ {
348353
name: '<?php _e( 'Posts', 'posts-and-users-stats' ); ?>',
349354
data: [ <?php foreach( $terms as $term ) {
350-
echo $term->count . ',';
351-
}?> ]
355+
echo $term->count . ',';
356+
} ?> ]
352357
} ],
353358
credits: {
354359
enabled: false
@@ -431,7 +436,7 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
431436
text: '<?php echo get_bloginfo( 'name' ); ?>'
432437
},
433438
xAxis: {
434-
categories: [
439+
categories: [
435440
<?php foreach( $posts_per_author as $author ) {
436441
echo "'" . $author['name'] . "',";
437442
}?> ],
@@ -448,11 +453,11 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
448453
series: [ {
449454
name: 'all',
450455
data: [ <?php foreach( $posts_per_author as $author ) {
451-
echo $author['total'] . ',';
452-
}?> ]
456+
echo $author['total'] . ',';
457+
} ?> ]
453458
} ],
454459
credits: {
455-
enabled: false
460+
enabled: false
456461
},
457462
exporting: {
458463
filename: '<?php echo posts_and_users_stats_get_export_file_name( __('Posts per Author', 'posts-and-users-stats' ) ); ?>'
@@ -473,10 +478,10 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
473478
xAxis: {
474479
categories: [
475480
<?php foreach( $posts_per_type as $type => $count ) {
476-
if ( $type != 'total' && $count > 0) {
481+
if ( $type != 'total' && $count > 0) {
477482
echo "'" . $type . "',";
478483
}
479-
}?> ],
484+
} ?> ],
480485
},
481486
yAxis: {
482487
title: {
@@ -490,10 +495,10 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
490495
series: [ {
491496
name: 'all',
492497
data: [ <?php foreach( $posts_per_type as $type => $count ) {
493-
if ( $type != 'total' && $count > 0) {
494-
echo $count . ',';
495-
}
496-
} ?> ]
498+
if ( $type != 'total' && $count > 0) {
499+
echo $count . ',';
500+
}
501+
} ?> ]
497502
} ],
498503
credits: {
499504
enabled: false
@@ -529,7 +534,7 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
529534
<td class="number"><?php if ( $post_type == 'post' ) {
530535
posts_and_users_stats_echo_link( get_author_posts_url( $author['ID'] ), $author['post'] );
531536
} else {
532-
echo $author[$post_type];
537+
echo $author[ $post_type ];
533538
} ?></td>
534539
<?php } ?>
535540
<td class="number"><strong><?php echo $author['total']; ?></strong></td>
@@ -542,7 +547,7 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
542547
<?php } ?>
543548
</tr>
544549
</tbody>
545-
</table>
550+
</table>
546551
</section>
547552

548553
<?php } else if ( $selected_tab == 'status' ) {
@@ -571,7 +576,7 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
571576
categories: [
572577
<?php foreach( $statuses as $status_slug => $status_name ) {
573578
echo "'" . $status_name . "',";
574-
}?> ],
579+
} ?> ],
575580
},
576581
yAxis: {
577582
title: {
@@ -585,11 +590,11 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
585590
series: [ {
586591
name: '<?php _e( 'Posts', 'posts-and-users-stats' ); ?>',
587592
data: [ <?php foreach( $statuses as $status_slug => $status_name ) {
588-
echo $posts_per_status->$status_slug . ',';
589-
}?> ]
593+
echo $posts_per_status->$status_slug . ',';
594+
} ?> ]
590595
} ],
591596
credits: {
592-
enabled: false
597+
enabled: false
593598
},
594599
exporting: {
595600
filename: '<?php echo posts_and_users_stats_get_export_file_name( __('Posts per Status', 'posts-and-users-stats' ) ); ?>'
@@ -618,7 +623,7 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
618623
</tr>
619624
<?php } ?>
620625
</tbody>
621-
</table>
626+
</table>
622627
</section>
623628
<?php } ?>
624629
<?php $end_time = microtime( true ); ?>

views/users.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
4747
text: '<?php echo get_bloginfo( 'name' ); ?>'
4848
},
4949
xAxis: {
50-
categories: [
50+
categories: [
5151
<?php foreach( $roles as $role => $count ) {
5252
echo "'" . $role . "',";
53-
}?> ],
53+
} ?> ],
5454
},
5555
yAxis: {
5656
title: {
@@ -63,11 +63,11 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
6363
},
6464
series: [ {
6565
data: [ <?php foreach( $roles as $role => $count ) {
66-
echo $count . ',';
67-
}?> ]
66+
echo $count . ',';
67+
} ?> ]
6868
} ],
6969
credits: {
70-
enabled: false
70+
enabled: false
7171
},
7272
exporting: {
7373
filename: '<?php echo posts_and_users_stats_get_export_file_name( __( 'Users per Role', 'posts-and-users-stats' ) ); ?>'
@@ -105,7 +105,9 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
105105
$user_registration_dates = $wpdb->get_results(
106106
"SELECT DATE(user_registered) AS date, count(*) as count
107107
FROM " . $wpdb->prefix . "users
108-
GROUP BY date ASC");
108+
GROUP BY date ASC",
109+
OBJECT_K
110+
);
109111
?>
110112
<section>
111113
<div id="chart-users-date" class="chart"></div>
@@ -148,11 +150,11 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
148150
$month = date( 'm', $date );
149151
$day = date( 'd', $date );
150152
$users += $registration->count;
151-
echo '[Date.UTC(' . $year . ',' . ( $month - 1 ) . ',' . $day . '), ' . $users . '], ';
152-
}?> ]
153+
echo '[Date.UTC(' . $year . ',' . ( $month - 1 ) . ',' . $day . '), ' . $users . '], ';
154+
} ?> ]
153155
} ],
154156
credits: {
155-
enabled: false
157+
enabled: false
156158
},
157159
exporting: {
158160
filename: '<?php echo posts_and_users_stats_get_export_file_name( __( 'Users over Time', 'posts-and-users-stats' ) ); ?>'
@@ -181,7 +183,7 @@ class="<?php posts_and_users_stats_echo_tab_class( $selected_tab == $tab_slug );
181183
</tr>
182184
<?php } ?>
183185
</tbody>
184-
</table>
186+
</table>
185187
</section>
186188
<?php } ?>
187189
<?php $end_time = microtime( true ); ?>

0 commit comments

Comments
 (0)