pmpro_report_memberships_widget

The Paid Memberships Pro pmpro report memberships widget function.

Description

pmpro_report_memberships_widget(); 

Usage

  1. if ( !function_exists( 'pmpro_report_memberships_widget' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/adminpages/reports/memberships.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = pmpro_report_memberships_widget(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/adminpages/reports/memberships.php  
  1. function pmpro_report_memberships_widget() { 
  2. global $wpdb; 
  3.  
  4. //get levels to show stats on first 3 
  5. $levels = pmpro_getAllLevels(true, true); 
  6. ?> 
  7. <span id="pmpro_report_memberships">  
  8. <table class="wp-list-table widefat fixed striped"> 
  9. <thead> 
  10. <tr> 
  11. <th scope="col"> </th> 
  12. <th scope="col"><?php _e('Signups', 'paid-memberships-pro' ); ?></th> 
  13. <th scope="col"><?php _e('All Cancellations', 'paid-memberships-pro' ); ?></th> 
  14. </tr> 
  15. </thead> 
  16. <?php 
  17. $reports = array( 
  18. 'today'=> __('Today', 'paid-memberships-pro' ),  
  19. 'this month'=> __('This Month', 'paid-memberships-pro' ),  
  20. 'this year'=> __('This Year', 'paid-memberships-pro' ),  
  21. 'all time'=> __('All Time', 'paid-memberships-pro' ),  
  22. ); 
  23.  
  24. foreach($reports as $report_type => $report_name) { 
  25. ?> 
  26. <tbody> 
  27. <tr class="pmpro_report_tr"> 
  28. <th scope="row"><button class="pmpro_report_th pmpro_report_th_closed"><?php echo $report_name; ?></button></th> 
  29. <td><?php echo number_format_i18n(pmpro_getSignups($report_type)); ?></td> 
  30. <td><?php echo number_format_i18n(pmpro_getCancellations($report_type)); ?></td> 
  31. </tr> 
  32. <?php 
  33. //level stats 
  34. $count = 0; 
  35. foreach($levels as $level) {  
  36. if($count++ > 2) break; 
  37. ?> 
  38. <tr class="pmpro_report_tr_sub" style="display: none;"> 
  39. <th scope="row">- <?php echo $level->name;?></th> 
  40. <td><?php echo number_format_i18n(pmpro_getSignups($report_type, $level->id)); ?></td> 
  41. <td><?php echo number_format_i18n(pmpro_getCancellations($report_type, $level->id)); ?></td> 
  42. </tr> 
  43. <?php  
  44. }  
  45. ?> 
  46. </tbody> 
  47. <?php 
  48. ?> 
  49. </table> 
  50. </span> 
  51. <script> 
  52. jQuery(document).ready(function() { 
  53. jQuery('.pmpro_report_th ').click(function() { 
  54. //toggle sub rows 
  55. jQuery(this).closest('tbody').find('.pmpro_report_tr_sub').toggle(); 
  56.  
  57. //change arrow 
  58. if(jQuery(this).hasClass('pmpro_report_th_closed')) { 
  59. jQuery(this).removeClass('pmpro_report_th_closed'); 
  60. jQuery(this).addClass('pmpro_report_th_opened'); 
  61. } else { 
  62. jQuery(this).removeClass('pmpro_report_th_opened'); 
  63. jQuery(this).addClass('pmpro_report_th_closed'); 
  64. }); 
  65. }); 
  66. </script> 
  67. <?php