monsterinsights_settings_general_tab

Callback for displaying the UI for general settings tab.

Description

monsterinsights_settings_general_tab(); 

Usage

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

Defined (1)

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

/includes/admin/settings/tab-general.php  
  1. function monsterinsights_settings_general_tab() { 
  2. // Get settings 
  3. $manual_ua_code = monsterinsights_get_option( 'manual_ua_code', '' ); 
  4. $manual_ua_code = esc_html( $manual_ua_code ); 
  5.  
  6. $ua_code = monsterinsights_get_ua(); 
  7. $license_key_type = ''; 
  8.  
  9. $network_license = get_site_option( monsterinsights_license ); 
  10. if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty ( $network_license ) ) ) { 
  11. $site_license = get_option( monsterinsights_license ); 
  12. $license_key = ! empty( $site_license['key'] ) ? esc_attr( $site_license['key'] ) : ''; 
  13. $license_key_type = ! empty( $site_license['type'] ) ? esc_html( $site_license['type'] ) : ''; 
  14.  
  15. $profile_name = monsterinsights_get_option( 'analytics_profile_name', '' ); 
  16. $profile_id = monsterinsights_get_option( 'analytics_profile', '' ); 
  17. $tracking_mode = monsterinsights_get_option( 'tracking_mode', 'analytics' ); 
  18. $events_mode = monsterinsights_get_option( 'events_mode', 'js' ); 
  19. $anon_tracking = monsterinsights_get_option( 'anonymous_data', false ); 
  20. ?> 
  21. <div id="monsterinsights-settings-general"> 
  22. <div class="monsterinsights-tab-settings-notices"> 
  23. <?php  
  24. // Output any notices now 
  25. /**  
  26. * Developer Alert: 
  27. * Per the README, this is considered an internal hook and should 
  28. * not be used by other developers. This hook's behavior may be modified 
  29. * or the hook may be removed at any time, without warning. 
  30. */ 
  31. ?> 
  32. </div> 
  33. <table class="form-table"> 
  34. <tbody> 
  35. <?php if ( ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty ( $network_license ) ) ) && monsterinsights_is_pro_version() ) { ?> 
  36. <tr id="monsterinsights-settings-key-box"> 
  37. <th scope="row"> 
  38. <label for="monsterinsights-settings-key"><?php esc_html_e( 'License Key', 'google-analytics-for-wordpress' ); ?></label> 
  39. </th> 
  40. <td> 
  41. <form id="monsterinsights-settings-verify-key" method="post"> 
  42. <input type="password" name="monsterinsights-license-key" id="monsterinsights-settings-key" value="<?php echo $license_key; ?>" /> 
  43. <?php wp_nonce_field( 'monsterinsights-key-nonce', 'monsterinsights-key-nonce' ); ?> 
  44. <?php submit_button( esc_html__( 'Verify Key', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-verify-submit', false ); ?> 
  45. <?php submit_button( esc_html__( 'Deactivate Key', 'google-analytics-for-wordpress' ), 'button-danger', 'monsterinsights-deactivate-submit', false ); ?> 
  46. <p class="description"><?php esc_html_e( 'License key to enable automatic updates for MonsterInsights Pro & addons. Deactivate your license if you want to use it on another WordPress site.', 'google-analytics-for-wordpress' ); ?></p> 
  47. </form> 
  48. </td> 
  49. </tr> 
  50. <?php if ( ! empty( $license_key_type ) && monsterinsights_is_pro_version() ) : ?> 
  51. <tr id="monsterinsights-settings-key-type-box"> 
  52. <th scope="row"> 
  53. <label for="monsterinsights-settings-key-type"><?php esc_html_e( 'License Key Type', 'google-analytics-for-wordpress' ); ?></label> 
  54. </th> 
  55. <td> 
  56. <form id="monsterinsights-settings-key-type" method="post"> 
  57. <span class="monsterinsights-license-type"><?php printf( esc_html__( 'Your license key type for this site is %s.', 'google-analytics-for-wordpress' ), '<strong>' . $license_key_type . '</strong>' ); ?> 
  58. <input type="hidden" name="monsterinsights-license-key" value="<?php echo $license_key; ?>" /> 
  59. <?php wp_nonce_field( 'monsterinsights-key-nonce', 'monsterinsights-key-nonce' ); ?> 
  60. <?php submit_button( esc_html__( 'Refresh Key', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-refresh-submit', false ); ?> 
  61. <p class="description"><?php esc_html_e( 'Your license key type (handles updates and Addons). Click refresh if your license has been upgraded or the type is incorrect.', 'google-analytics-for-wordpress' ); ?></p> 
  62. </form> 
  63. </td> 
  64. </tr> 
  65. <?php endif; ?> 
  66. <?php } ?> 
  67.  
  68. <tr id="monsterinsights-google-authenticate-box"> 
  69. <th scope="row"> 
  70. <?php if ( $profile_name && $ua_code ) { ?> 
  71. <label for="monsterinsights-google-authenticate"><?php esc_html_e( 'Analytics Profile', 'google-analytics-for-wordpress' ); ?></label> 
  72. <?php } else { ?> 
  73. <label for="monsterinsights-google-authenticate"><?php esc_html_e( 'Google Authentication', 'google-analytics-for-wordpress' ); ?></label> 
  74. <?php } ?> 
  75. </th> 
  76. <td> 
  77. <form id="monsterinsights-google-authenticate" method="post"> 
  78. <?php if ( $profile_name && $ua_code ) { ?> 
  79. <p><?php echo esc_html__( 'Profile Active: ', 'google-analytics-for-wordpress' ) . $profile_name; ?></p> 
  80. <p><?php wp_nonce_field( 'monsterinsights-google-authenticated-nonce', 'monsterinsights-google-authenticated-nonce' ); ?> 
  81. <?php submit_button( esc_html__( 'Re-Authenticate with your Google account', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-google-reauthenticate-submit', false ); ?> 
  82. <?php submit_button( esc_html__( 'Deauthenticate', 'google-analytics-for-wordpress' ), 'button-danger', 'monsterinsights-google-deauthenticate-submit', false ); ?></p> 
  83. <?php } else { ?> 
  84. <?php wp_nonce_field( 'monsterinsights-google-authenticate-nonce', 'monsterinsights-google-authenticate-nonce' ); ?> 
  85. <?php submit_button( esc_html__( 'Authenticate with your Google account', 'google-analytics-for-wordpress' ), 'button-action', 'monsterinsights-google-authenticate-submit', false ); ?> 
  86. <p class="description"><?php printf( esc_html__( 'Having issues automatically authenticating? %s Click here to authenticate manually %s.', 'google-analytics-for-wordpress' ), '<a href="javascript:monsterinsights_show_manual()" data-action="show-manual-ua-box">', '</a>' ); ?></p> 
  87. <?php } ?> 
  88. </form> 
  89. </td> 
  90. </tr> 
  91. </tbody> 
  92. </table> 
  93.  
  94. <!-- <hr /> --> 
  95.  
  96. <!-- Settings Form --> 
  97. <form id="monsterinsights-general-tab" method="post"> 
  98. <table class="form-table"> 
  99. <tbody> 
  100. <?php if ( ! $profile_name ) { ?> 
  101. <!-- Manual UA --> 
  102. <tr id="monsterinsights-google-ua-box" <?php echo ( ! $ua_code ? 'class="monsterinsights-hideme"' : ''); ?> > 
  103. <th scope="row"> 
  104. <label for="monsterinsights-google-ua"><?php esc_html_e( 'Manually enter your UA code', 'google-analytics-for-wordpress' ); ?></label> 
  105. </th> 
  106. <td> 
  107. <input type="text" id="monsterinsights-google-ua" name="manual_ua_code" value="<?php echo $manual_ua_code; ?>" /> 
  108. <p class="description"><?php esc_html_e( 'Warning: If you use a manual UA code, you won\'t be able to use the dashboard or reports.', 'google-analytics-for-wordpress' ); ?></p> 
  109. </td> 
  110. </tr> 
  111. <?php } ?> 
  112.  
  113. <!-- Disable Dashboard --> 
  114. <?php 
  115. $title = esc_html__( 'Disable Dashboard', 'google-analytics-for-wordpress' ); 
  116. $description = esc_html__( 'Hide the dashboard and reports pages.', 'google-analytics-for-wordpress' ); 
  117. echo monsterinsights_make_checkbox( 'dashboards_disabled', $title, $description ); 
  118. ?> 
  119.  
  120. <?php if ( $tracking_mode === 'ga' || monsterinsights_is_debug_mode() ) { ?> 
  121. <tr id="monsterinsights-tracking-mode"> 
  122. <th scope="row"> 
  123. <label for="monsterinsights-tracking-mode"><?php esc_html_e( 'Pick Tracking Mode', 'google-analytics-for-wordpress' ); ?></label> 
  124. </th> 
  125. <td> 
  126. <?php 
  127. $url = esc_url( wp_nonce_url( add_query_arg( array( 'monsterinsights-action' => 'switch_to_analyticsjs', 'return' => 'general' ) ), 'monsterinsights-switch-to-analyticsjs-nonce' ) ); 
  128. ?> 
  129. <label><input type="radio" name="tracking_mode" value="ga" <?php checked( $tracking_mode, 'ga' ); ?> ><?php esc_html_e('GA.js (Deprecated)', 'google-analytics-for-wordpress'); ?> </label> 
  130. <label><input type="radio" name="tracking_mode" value="analytics" <?php checked( $tracking_mode, 'analytics' ); ?> ><?php esc_html_e( 'Analytics.js (Universal Analytics)', 'google-analytics-for-wordpress'); ?> </label> 
  131. <?php if ($tracking_mode === 'ga' ) { ?> 
  132. <?php echo monsterinsights_get_message( error, sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking. We recommend switching to analytics.js, as it is significantly more accurate than ga.js, and allows for functionality (like the more accurate Javascript based events tracking we offer). Further Google Analytics has deprecated support for ga.js, and it may stop working at any time when Google decides to disable it from their server. To switch to using the newer Universal Analytics (analytics.js) %1$sclick here%2$s.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ) ); 
  133. ?> 
  134. <?php } ?> 
  135. </td> 
  136. </tr> 
  137. <?php } ?> 
  138.  
  139. <?php if ( $tracking_mode !== 'ga' && $events_mode === 'php' ) { ?> 
  140. <tr id="monsterinsights-tracking-mode"> 
  141. <th scope="row"> 
  142. <label for="monsterinsights-tracking-mode"><?php esc_html_e( 'Switch to JS events tracking', 'google-analytics-for-wordpress' ); ?></label> 
  143. </th> 
  144. <td> 
  145. <?php 
  146. $url = esc_url( wp_nonce_url( add_query_arg( array( 'monsterinsights-action' => 'switch_to_jsevents', 'return' => 'general' ) ), 'monsterinsights-switch-to-jsevents-nonce' ) ); 
  147. ?> 
  148. <?php echo monsterinsights_get_message( error, sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking and we will eventually discontinue PHP based events tracking. To switch %1$sclick here%2$s.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ) ); 
  149. ?> 
  150. </td> 
  151. </tr> 
  152. <?php } ?> 
  153.  
  154. <!-- Tracking --> 
  155. <?php 
  156. $title = esc_html__( 'Allow Usage Tracking', 'google-analytics-for-wordpress' ); 
  157. $description = esc_html__( 'By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress' ); 
  158. if ( ! $anon_tracking || monsterinsights_is_debug_mode() ) { 
  159. echo monsterinsights_make_checkbox( 'anonymous_data', $title, $description ); 
  160. ?> 
  161.  
  162. <?php  
  163. /**  
  164. * Developer Alert: 
  165. * Per the README, this is considered an internal hook and should 
  166. * not be used by other developers. This hook's behavior may be modified 
  167. * or the hook may be removed at any time, without warning. 
  168. */ 
  169. ?> 
  170. </tbody> 
  171. </table> 
  172. <input type="hidden" name="monsterinsights_settings_tab" value="general"/> 
  173. <?php wp_nonce_field( 'monsterinsights-settings-nonce', 'monsterinsights-settings-nonce' ); ?> 
  174. <?php submit_button( esc_html__( 'Save Changes', 'google-analytics-for-wordpress' ), 'primary', 'monsterinsights-settings-submit', false ); ?> 
  175. </form> 
  176. </div> 
  177. <?php