Changeset 706011
- Timestamp:
- 04/30/2013 04:25:11 PM (13 years ago)
- Location:
- jetpack/trunk
- Files:
-
- 2 edited
-
modules/stats.php (modified) (9 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
jetpack/trunk/modules/stats.php
r692359 r706011 12 12 } 13 13 14 define( 'STATS_VERSION', ' 8' );14 define( 'STATS_VERSION', '9' ); 15 15 defined( 'STATS_DASHBOARD_SERVER' ) or define( 'STATS_DASHBOARD_SERVER', 'dashboard.wordpress.com' ); 16 16 … … 89 89 */ 90 90 function stats_map_meta_caps( $caps, $cap, $user_id, $args ) { 91 92 91 // Map view_stats to exists 93 92 if ( 'view_stats' == $cap ) { … … 112 111 113 112 $options = stats_get_options(); 114 // Ensure this is always setup for the check below 115 $options['reg_users'] = empty( $options['reg_users'] ) ? false : true; 116 117 if ( !$options['reg_users'] && !empty( $current_user->ID ) ) 118 return; 113 114 // Should we be counting this user's views? 115 if ( !empty( $current_user->ID ) ) { 116 $count_roles = stats_get_option( 'count_roles' ); 117 if ( ! array_intersect( $current_user->roles, $count_roles ) ) 118 return; 119 } 119 120 120 121 add_action( 'wp_footer', 'stats_footer', 101 ); … … 208 209 'admin_bar' => true, 209 210 'roles' => array( 'administrator' ), 211 'count_roles' => array(), 210 212 'blog_id' => Jetpack::get_option( 'id' ), 211 213 'do_not_track' => true, // @todo 212 214 'hide_smile' => false, 213 215 ); 216 217 if ( isset( $options['reg_users'] ) ) { 218 if ( $options['reg_users'] ) 219 $options['count_roles'] = array_keys( get_editable_roles() ); 220 unset( $options['reg_users'] ); 221 } 214 222 215 223 if ( is_array( $options ) && !empty( $options ) ) … … 487 495 $options = stats_get_options(); 488 496 $options['admin_bar'] = isset( $_POST['admin_bar'] ) && $_POST['admin_bar']; 489 $options['reg_users'] = isset( $_POST['reg_users'] ) && $_POST['reg_users'];490 497 $options['hide_smile'] = isset( $_POST['hide_smile'] ) && $_POST['hide_smile']; 491 498 … … 494 501 if ( isset( $_POST["role_$role"] ) && $_POST["role_$role"] ) 495 502 $options['roles'][] = $role; 503 504 $options['count_roles'] = array(); 505 foreach ( get_editable_roles() as $role => $details ) 506 if ( isset( $_POST["count_role_$role"] ) && $_POST["count_role_$role"] ) 507 $options['count_roles'][] = $role; 496 508 497 509 stats_set_options( $options ); … … 520 532 function stats_configuration_screen() { 521 533 $options = stats_get_options(); 522 $options['reg_users'] = empty( $options['reg_users'] ) ? false : true;523 534 ?> 524 535 <div class="narrow"> … … 530 541 <tr valign="top"><th scope="row"><label for="admin_bar"><?php _e( 'Admin bar' , 'jetpack' ); ?></label></th> 531 542 <td><label><input type='checkbox'<?php checked( $options['admin_bar'] ); ?> name='admin_bar' id='admin_bar' /> <?php _e( "Put a chart showing 48 hours of views in the admin bar.", 'jetpack' ); ?></label></td></tr> 532 <tr valign="top"><th scope="row"><label for="reg_users"><?php _e( 'Registered users', 'jetpack' ); ?></label></th> 533 <td><label><input type='checkbox'<?php checked( $options['reg_users'] ); ?> name='reg_users' id='reg_users' /> <?php _e( "Count the page views of registered users who are logged in.", 'jetpack' ); ?></label></td></tr> 543 <tr valign="top"><th scope="row"><?php _e( 'Registered users', 'jetpack' ); ?></th> 544 <td> 545 <?php _e( "Count the page views of registered users who are logged in.", 'jetpack' ); ?><br/> 546 <?php 547 $count_roles = stats_get_option( 'count_roles' ); 548 foreach ( get_editable_roles() as $role => $details ) { 549 ?> 550 <label><input type='checkbox' name='count_role_<?php echo $role; ?>'<?php checked( in_array( $role, $count_roles ) ); ?> /> <?php echo translate_user_role( $details['name'] ); ?></label><br/> 551 <?php 552 } 553 ?> 554 </td></tr> 534 555 <tr valign="top"><th scope="row"><?php _e( 'Smiley' , 'jetpack' ); ?></th> 535 556 <td><label><input type='checkbox'<?php checked( isset( $options['hide_smile'] ) && $options['hide_smile'] ); ?> name='hide_smile' id='hide_smile' /> <?php _e( 'Hide the stats smiley face image.', 'jetpack' ); ?></label><br /> <span class="description"><?php _e( 'The image helps collect stats and <strong>makes the world a better place</strong> but should still work when hidden', 'jetpack' ); ?> <img class="stats-smiley" alt="<?php esc_attr_e( 'Smiley face', 'jetpack' ); ?>" src="<?php echo esc_url( plugins_url( '_inc/images/stats-smiley.gif', dirname( __FILE__ ) ) ); ?>" width="6" height="5" /></span></td></tr> … … 545 566 } 546 567 ?> 547 </t r>568 </td></tr> 548 569 </table> 549 570 <p class="submit"><input type='submit' class='button-primary' value='<?php echo esc_attr( __( 'Save configuration', 'jetpack' ) ); ?>' /></p> -
jetpack/trunk/readme.txt
r704411 r706011 79 79 80 80 == Changelog == 81 82 = trunk = 83 * Enhancement: Stats: Counting of registered users' views can now be enabled for specific roles 81 84 82 85 = 2.2.4 =
Note: See TracChangeset
for help on using the changeset viewer.