| 1 |
<?php |
| 2 |
### Variables Variables Variables |
| 3 |
$base_name = plugin_basename( 'wp-stats/stats-options.php' ); |
| 4 |
$base_page = 'admin.php?page=' . $base_name; |
| 5 |
|
| 6 |
### Form Processing |
| 7 |
if ( ! empty( $_POST['Submit'] ) ) { |
| 8 |
check_admin_referer( 'wp-stats_options' ); |
| 9 |
$stats_url = ! empty( $_POST['stats_url'] ) ? esc_url_raw( $_POST['stats_url'] ) : ''; |
| 10 |
$stats_mostlimit = ! empty( $_POST['stats_mostlimit'] ) ? (int) trim( $_POST['stats_mostlimit'] ) : 10; |
| 11 |
$stats_display = ! empty( $_POST['stats_display'] ) ? $_POST['stats_display'] : array(); |
| 12 |
$stats_display_array = array(); |
| 13 |
if ( ! empty( $stats_display ) ) { |
| 14 |
foreach ( $stats_display as $stat_display ) { |
| 15 |
$stat_display = addslashes( $stat_display ); |
| 16 |
$stats_display_array[ $stat_display ] = 1; |
| 17 |
} |
| 18 |
} |
| 19 |
$stats_display = $stats_display_array; |
| 20 |
$update_stats_queries = array(); |
| 21 |
$update_stats_text = array(); |
| 22 |
$update_stats_queries[] = update_option( 'stats_url', $stats_url ); |
| 23 |
$update_stats_queries[] = update_option( 'stats_mostlimit', $stats_mostlimit) ; |
| 24 |
$update_stats_queries[] = update_option( 'stats_display', $stats_display ); |
| 25 |
$update_stats_text[] = __( 'Stats URL', 'wp-stats' ); |
| 26 |
$update_stats_text[] = __( 'Stats Most Limit', 'wp-stats' ); |
| 27 |
$update_stats_text[] = __( 'Stats Display Options', 'wp-stats' ); |
| 28 |
$i=0; |
| 29 |
$text = ''; |
| 30 |
foreach( $update_stats_queries as $update_stats_query ) { |
| 31 |
if ( $update_stats_query ) { |
| 32 |
$text .= '<p style="color: green">' . $update_stats_text[ $i ] . ' ' . __( 'Updated', 'wp-stats' ) . '</p>'; |
| 33 |
} |
| 34 |
$i++; |
| 35 |
} |
| 36 |
if ( empty( $text ) ) { |
| 37 |
$text = '<p style="color: red">' . __( 'No Stats Option Updated', 'wp-stats' ) . '</p>'; |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
$stats_mostlimit = (int) get_option( 'stats_mostlimit' ); |
| 42 |
$stats_display = get_option( 'stats_display' ); |
| 43 |
$stats_display['total_stats'] = isset( $stats_display['total_stats'] ) ? (int) $stats_display['total_stats'] : 0; |
| 44 |
$stats_display['recent_posts'] = isset( $stats_display['recent_posts'] ) ? (int) $stats_display['recent_posts'] : 0; |
| 45 |
$stats_display['recent_comments'] = isset( $stats_display['recent_comments'] ) ? (int) $stats_display['recent_comments'] : 0; |
| 46 |
$stats_display['commented_post'] = isset( $stats_display['commented_post'] ) ? (int) $stats_display['commented_post'] : 0; |
| 47 |
$stats_display['commented_page'] = isset( $stats_display['commented_page'] ) ? (int) $stats_display['commented_page'] : 0; |
| 48 |
$stats_display['authors'] = isset( $stats_display['authors'] ) ? (int) $stats_display['authors'] : 0; |
| 49 |
$stats_display['comment_members'] = isset( $stats_display['comment_members'] ) ? (int) $stats_display['comment_members'] : 0; |
| 50 |
$stats_display['post_cats'] = isset( $stats_display['post_cats'] ) ? (int) $stats_display['post_cats'] : 0; |
| 51 |
$stats_display['link_cats'] = isset( $stats_display['link_cats'] ) ? (int) $stats_display['link_cats'] : 0; |
| 52 |
$stats_display['tags_list'] = isset( $stats_display['tags_list'] ) ? (int) $stats_display['tags_list'] : 0; |
| 53 |
|
| 54 |
$page_admin_general_stats = ''; |
| 55 |
$page_admin_plugins_stats = ''; |
| 56 |
$page_admin_recent_stats = ''; |
| 57 |
$page_page_admin_most_stats = ''; |
| 58 |
$page_admin_authors_stats = ''; |
| 59 |
$admin_comments_members_stats = ''; |
| 60 |
$page_admin_misc_stats = ''; |
| 61 |
?> |
| 62 |
<?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?> |
| 63 |
<form method="post" action="<?php echo admin_url( 'admin.php?page='.plugin_basename( __FILE__ ) ); ?>"> |
| 64 |
<?php wp_nonce_field( 'wp-stats_options' ); ?> |
| 65 |
<div class="wrap"> |
| 66 |
<h2><?php _e('Stats Options', 'wp-stats'); ?></h2> |
| 67 |
<table class="form-table"> |
| 68 |
<tr> |
| 69 |
<th scope="row" valign="top"><?php _e('Stats URL', 'wp-stats'); ?></th> |
| 70 |
<td> |
| 71 |
<input type="text" name="stats_url" value="<?php echo esc_url( get_option( 'stats_url' ) ); ?>" size="50" dir="ltr" /><br /><?php _e('URL To Stats Page.<br />Example: http://www.yoursite.com/blogs/stats/<br />Example: http://www.yoursite.com/blogs/?page_id=2', 'wp-stats'); ?> |
| 72 |
</td> |
| 73 |
</tr> |
| 74 |
<tr> |
| 75 |
<th scope="row" valign="top"><?php _e('Stats Most Limit', 'wp-stats'); ?></th> |
| 76 |
<td> |
| 77 |
<input type="text" name="stats_mostlimit" value="<?php echo $stats_mostlimit ?>" size="2" /><br /><?php _e('Top X Stats, where X is the most limit.', 'wp-stats'); ?> |
| 78 |
</td> |
| 79 |
</tr> |
| 80 |
<tr> |
| 81 |
<th scope="row" valign="top"><?php _e('Type Of Stats To Display', 'wp-stats'); ?></th> |
| 82 |
<td> |
| 83 |
<p><strong><?php _e('General Stats', 'wp-stats'); ?></strong></p> |
| 84 |
<input type="checkbox" name="stats_display[]" id="wpstats_total_stats" value="total_stats"<?php checked(1, $stats_display['total_stats']); ?> /> <label for="wpstats_total_stats"><?php _e('Total', 'wp-stats'); ?></label><br /> |
| 85 |
|
| 86 |
<!-- Admin General Stats Filter --> |
| 87 |
<?php echo apply_filters('wp_stats_page_admin_general', $page_admin_general_stats); ?> |
| 88 |
|
| 89 |
<p><strong><?php _e('Plugin Stats', 'wp-stats'); ?></strong></p> |
| 90 |
|
| 91 |
<!-- Admin Plugins Stats Filter --> |
| 92 |
<?php echo apply_filters('wp_stats_page_admin_plugins', $page_admin_plugins_stats); ?> |
| 93 |
|
| 94 |
<p><strong><?php printf(_n('Top %s Recent Stat', 'Top %s Recent Stats', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)); ?></strong></p> |
| 95 |
<input type="checkbox" name="stats_display[]" id="wpstats_recent_posts" value="recent_posts"<?php checked(1, $stats_display['recent_posts']); ?> /> <label for="wpstats_recent_posts"><?php printf(_n('%s Most Recent Post', '%s Most Recent Posts', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)); ?></label><br /> |
| 96 |
<input type="checkbox" name="stats_display[]" id="wpstats_recent_comments" value="recent_comments"<?php checked(1, $stats_display['recent_comments']); ?> /> <label for="wpstats_recent_comments"><?php printf(_n( '%s Most Recent Comment', '%s Most Recent Comments', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)); ?></label><br /> |
| 97 |
|
| 98 |
<!-- Admin Recent Stats Filter --> |
| 99 |
<?php echo apply_filters('wp_stats_page_admin_recent', $page_admin_recent_stats); ?> |
| 100 |
|
| 101 |
<p><strong><?php printf(_n('Top %s Most/Highest Stat', 'Top %s Most/Highest Stats', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)); ?></strong></p> |
| 102 |
<input type="checkbox" name="stats_display[]" id="wpstats_commented_post" value="commented_post"<?php checked(1, $stats_display['commented_post']); ?> /> <label for="wpstats_commented_post"><?php printf(_n( '%s Most Commented Post', '%s Most Commented Posts', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)); ?></label><br /> |
| 103 |
<input type="checkbox" name="stats_display[]" id="wpstats_commented_page" value="commented_page"<?php checked(1, $stats_display['commented_page']); ?> /> <label for="wpstats_commented_page"><?php printf(_n( '%s Most Commented Page', '%s Most Commented Pages', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)); ?></label><br /> |
| 104 |
|
| 105 |
|
| 106 |
<!-- Admin Most Stats Filter --> |
| 107 |
<?php echo apply_filters('wp_stats_page_admin_most', $page_page_admin_most_stats); ?> |
| 108 |
|
| 109 |
<p><strong><?php _e('Authors Stats', 'wp-stats'); ?></strong></p> |
| 110 |
<input type="checkbox" name="stats_display[]" id="wpstats_authors" value="authors"<?php checked(1, $stats_display['authors']); ?> /> <label for="wpstats_authors"><?php _e('Authors', 'wp-stats'); ?></label><br /> |
| 111 |
|
| 112 |
<!-- Admin Authors Stats Filter --> |
| 113 |
<?php echo apply_filters('wp_stats_page_admin_authors', $page_admin_authors_stats); ?> |
| 114 |
|
| 115 |
<p><strong><?php _e('Comments\' Members Stats', 'wp-stats'); ?></strong></p> |
| 116 |
<input type="checkbox" name="stats_display[]" id="wpstats_comment_members" value="comment_members"<?php checked(1, $stats_display['comment_members']); ?> /> <label for="wpstats_comment_members"><?php _e('Comment Members', 'wp-stats'); ?></label><br /> |
| 117 |
|
| 118 |
<!-- Admin Comments' Members Stats Filter --> |
| 119 |
<?php echo apply_filters('wp_stats_page_admin_comments_members', $admin_comments_members_stats); ?> |
| 120 |
|
| 121 |
<p><strong><?php _e('Misc Stats', 'wp-stats'); ?></strong></p> |
| 122 |
<input type="checkbox" name="stats_display[]" id="wpstats_post_cats" value="post_cats"<?php checked(1, $stats_display['post_cats']); ?> /> <label for="wpstats_post_cats"><?php _e('Post Categories', 'wp-stats'); ?></label><br /> |
| 123 |
<input type="checkbox" name="stats_display[]" id="wpstats_link_cats" value="link_cats"<?php checked(1, $stats_display['link_cats']); ?> /> <label for="wpstats_link_cats"><?php _e('Link Categories', 'wp-stats'); ?></label><br /> |
| 124 |
<input type="checkbox" name="stats_display[]" id="wpstats_tags_list" value="tags_list"<?php checked(1, $stats_display['tags_list']); ?> /> <label for="wpstats_tags_list"><?php _e('Tags List', 'wp-stats'); ?></label><br /> |
| 125 |
|
| 126 |
<!-- Admin Misc Stats Filter --> |
| 127 |
<?php echo apply_filters('wp_stats_page_admin_misc', $page_admin_misc_stats); ?> |
| 128 |
</td> |
| 129 |
</tr> |
| 130 |
</table> |
| 131 |
<p class="submit"> |
| 132 |
<input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-stats'); ?>" /> |
| 133 |
</p> |
| 134 |
</div> |
| 135 |
</form> |