monsterinsights_reports_page

Callback to output the MonsterInsights reports page.

Description

monsterinsights_reports_page(); 

Usage

  1. if ( !function_exists( 'monsterinsights_reports_page' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/admin/pages/reports.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = monsterinsights_reports_page(); 
  7.  

Defined (1)

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

/includes/admin/pages/reports.php  
  1. function monsterinsights_reports_page() { 
  2. /**  
  3. * Developer Alert: 
  4. * Per the README, this is considered an internal hook and should 
  5. * not be used by other developers. This hook's behavior may be modified 
  6. * or the hook may be removed at any time, without warning. 
  7. */ 
  8. do_action( 'monsterinsights_head' ); 
  9.  
  10. if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) { 
  11. wp_die( esc_html__( 'Access denied' , 'google-analytics-for-wordpress' ) ); 
  12.  
  13. $dashboard_disabled = monsterinsights_get_option( 'dashboard_disabled', false ); 
  14. $profile_enabled = monsterinsights_get_option( 'analytics_profile', false ); // not using profile 
  15. $oauth_version = monsterinsights_get_option( 'oauth_version', '1.0' ); 
  16. $last_run = monsterinsights_get_option( 'cron_last_run', false ); 
  17. $failed = monsterinsights_get_option( 'cron_failed', false ); 
  18. $pro_access_key = get_option( 'monsterinsights_pro_access_token', false ); 
  19. $lite_access_key = get_option( 'monsterinsights_lite_access_token', false ); 
  20. $needs_re_auth = ( ( $failed && ( $last_run === false || monsterinsights_hours_between( $last_run ) >= 48 ) ) || ( empty( $pro_access_key ) && empty( $lite_access_key ) ) || ( version_compare( $oauth_version, '1.0', '<' ) ) ) ? true : false; 
  21. ?> 
  22. <?php echo monsterinsights_ublock_notice(); ?> 
  23.  
  24. <!-- Tabs --> 
  25. <h1 id="monsterinsights-reports-page-main-nav" class="monsterinsights-main-nav-container monsterinsights-nav-container" data-container="#monsterinsights-reports-pages" data-update-hashbang="1"> 
  26. <?php  
  27. $i = 0; 
  28. ?> 
  29. <a class="monsterinsights-main-nav-item monsterinsights-nav-item monsterinsights-spacing-item" href="#"> </a> 
  30. <?php 
  31. foreach ( (array) monsterinsights_get_reports() as $id => $title ) { 
  32. $class = ( 0 === $i ? 'monsterinsights-active' : '' );  
  33. ?> 
  34. <a class="monsterinsights-main-nav-item monsterinsights-nav-item <?php echo $class; ?>" href="#monsterinsights-main-tab-<?php echo esc_attr( $id ); ?>" title="<?php echo esc_attr( $title ); ?>"> 
  35. <?php echo esc_html( $title ); ?> 
  36. </a> 
  37. <?php  
  38. $i++;  
  39. ?> 
  40. </h1> 
  41.  
  42. <div id="monsterinsights-reports" class="wrap"> 
  43. <div class="monsterinsights-clear"> 
  44. <div class="monsterinsights-reports-action-bar"> 
  45. <div class="monsterinsights-reports-action-bar-title"> 
  46. <?php esc_html_e( 'Reports', 'google-analytics-for-wordpress' );?> 
  47. </div> 
  48. <div class="monsterinsights-reports-action-bar-actions"><?php  
  49. /**  
  50. * Developer Alert: 
  51. * Per the README, this is considered an internal hook and should 
  52. * not be used by other developers. This hook's behavior may be modified 
  53. * or the hook may be removed at any time, without warning. 
  54. */ 
  55. ?>  
  56. </div> 
  57. </div> 
  58.  
  59. <!-- Tab Panels --> 
  60. <div id="monsterinsights-reports-pages" class="monsterinsights-main-nav-tabs monsterinsights-nav-tabs" data-navigation="#monsterinsights-reports-page-main-nav"> 
  61. <h1 class="monsterinsights-hideme"></h1><!-- sowpnotices are below the nav bar --> 
  62. <?php  
  63. $i = 0;  
  64. foreach ( (array) monsterinsights_get_reports() as $id => $title ) { 
  65. $class = ( 0 === $i ? 'monsterinsights-active' : '' );  
  66. ?> 
  67. <div id="monsterinsights-main-tab-<?php echo esc_attr( $id ); ?>" class="monsterinsights-main-nav-tab monsterinsights-nav-tab <?php echo $class; ?>"> 
  68. <?php if ( $dashboard_disabled ) { ?> 
  69. <?php  
  70. if ( current_user_can( 'monsterinsights_save_settings' ) ) { 
  71. echo monsterinsights_get_message( error, sprintf( 
  72. sprintf( 
  73. esc_html__( 'Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress' ),  
  74. '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',  
  75. '</a>' 
  76. ) ); 
  77. } else { 
  78. echo monsterinsights_get_message( error, esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); 
  79. ?> 
  80. <?php } else if ( ! $profile_enabled ) { ?> 
  81. <?php  
  82. if ( current_user_can( 'monsterinsights_save_settings' ) ) { 
  83. echo monsterinsights_get_message( error, sprintf( 
  84. sprintf( 
  85. esc_html__( 'Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ),  
  86. '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',  
  87. '</a>' 
  88. ) ); 
  89. } else { 
  90. echo monsterinsights_get_message( error, esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); 
  91. ?> 
  92. <?php } else if ( $needs_re_auth ) { ?> 
  93. <?php  
  94. if ( current_user_can( 'monsterinsights_save_settings' ) ) { 
  95. echo monsterinsights_get_message( error, sprintf( 
  96. sprintf( 
  97. esc_html__( 'Please %1$sre-authenticate%2$s with Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ),  
  98. '<a href="' . admin_url( 'admin.php?page=monsterinsights_settings' ) . '">',  
  99. '</a>' 
  100. ) ); 
  101. } else { 
  102. echo monsterinsights_get_message( error, esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); 
  103. ?> 
  104. <?php } else if ( $failed ) { ?> 
  105. <?php  
  106. if ( current_user_can( 'monsterinsights_save_settings' ) ) { 
  107. echo monsterinsights_get_message( error, sprintf( 
  108. sprintf( 
  109. esc_html__( 'Data is not up-to-date, there was anerrorin retrieving the data from Google Analytics. Thiserrorcould be caused by several issues. If theerrorpersists, please see %1$sthis page%2$s.', 'google-analytics-for-wordpress' ),  
  110. '<a href="https://www.monsterinsights.com/docs/blocked-connection/">',  
  111. '</a>' 
  112. ) ); 
  113. } else { 
  114. echo monsterinsights_get_message( error, esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) ); 
  115. ?> 
  116. <?php } else { ?> 
  117. <div class="monsterinsights-reports-wrap"> 
  118. <?php 
  119. /**  
  120. * Developer Alert: 
  121. * Per the README, this is considered an internal hook and should 
  122. * not be used by other developers. This hook's behavior may be modified 
  123. * or the hook may be removed at any time, without warning. 
  124. */ 
  125. ?> 
  126. <?php do_action( 'monsterinsights_tab_reports_notices' ); ?> 
  127. <?php 
  128. /**  
  129. * Developer Alert: 
  130. * Per the README, this is considered an internal hook and should 
  131. * not be used by other developers. This hook's behavior may be modified 
  132. * or the hook may be removed at any time, without warning. 
  133. */ 
  134. ?> 
  135. <?php do_action( 'monsterinsights_tab_reports_' . $id ); ?> 
  136. </div> 
  137. <?php } ?> 
  138. </div> 
  139. <?php 
  140. $i++; 
  141. ?> 
  142. </div> 
  143. </div> 
  144. </div> 
  145. <?php