PageRenderTime 24ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/google-analytics-for-wordpress/admin/pages/dashboard.php

https://gitlab.com/iamgraeme/royalmile
PHP | 274 lines | 229 code | 27 blank | 18 comment | 26 complexity | b583ecf3e5eab9a10fa282c2d98e92a7 MD5 | raw file
  1. <?php
  2. /**
  3. * @package GoogleAnalytics\Admin
  4. */
  5. global $yoast_ga_admin;
  6. $options_class = Yoast_GA_Options::instance();
  7. $options = $options_class->get_options();
  8. $tracking_code = $options_class->get_tracking_code();
  9. echo $yoast_ga_admin->content_head();
  10. ?>
  11. <h2 id="yoast_ga_title"><?php echo __( 'Google Analytics by MonsterInsights: ', 'google-analytics-for-wordpress' ) . __( 'Dashboard', 'google-analytics-for-wordpress' ); ?> <?php do_action( 'yst_ga_dashboard_title' ); ?></h2>
  12. <h2 class="nav-tab-wrapper" id="ga-tabs">
  13. <a class="nav-tab" id="general-tab" href="#top#general"><?php _e( 'Overview', 'google-analytics-for-wordpress' ); ?></a>
  14. <a class="nav-tab" id="dimensions-tab" href="#top#dimensions"><?php _e( 'Reports', 'google-analytics-for-wordpress' ); ?></a>
  15. <a class="nav-tab" id="customdimensions-tab" href="#top#customdimensions"><?php _e( 'Custom dimension reports', 'google-analytics-for-wordpress' ); ?></a>
  16. <a class="nav-tab" id="systeminfo-tab" href="#top#systeminfo"><?php _e( 'System Info', 'google-analytics-for-wordpress' ); ?></a>
  17. </h2>
  18. <script type="text/javascript">
  19. var yoast_ga_dashboard_nonce = '<?php echo wp_create_nonce( 'yoast-ga-dashboard-nonce' ); ?>';
  20. jQuery(function () {
  21. jQuery.each(
  22. jQuery('select[data-rel=toggle_dimensions]'),
  23. function (num, element) {
  24. dimension_switch(element);
  25. }
  26. );
  27. });
  28. </script>
  29. <div class="tabwrapper">
  30. <div id="general" class="wpseotab gatab active">
  31. <div class="yoast-graphs">
  32. <?php
  33. if ( $tracking_code !== '' ) {
  34. if ( empty( $options['analytics_profile'] ) ) {
  35. echo '<div class="ga-promote"><p>';
  36. echo sprintf(
  37. __( 'We need you to authenticate with Google Analytics to use this functionality. If you set your UA-code manually, this won\'t work. You can %sauthenticate your Google Analytics profile here%s to enable dashboards.', 'google-analytics-for-wordpress' ),
  38. '<a href=" ' . admin_url( 'admin.php?page=yst_ga_settings#top#general' ) . '">',
  39. '</a>'
  40. );
  41. echo '</p></div>';
  42. }
  43. else if ( ! Yoast_Google_Analytics::get_instance()->has_refresh_token() ) {
  44. echo '<div class="ga-promote"><p>';
  45. echo sprintf(
  46. __( 'Because we\'ve switched to a newer version of the Google Analytics API, you\'ll need to re-authenticate with Google Analytics. We\'re sorry for the inconvenience. You can %sre-authenticate your Google Analytics profile here%s.', 'google-analytics-for-wordpress' ),
  47. '<a href=" ' . admin_url( 'admin.php?page=yst_ga_settings#top#general' ) . '">',
  48. '</a>'
  49. );
  50. echo '</p></div>';
  51. }
  52. else {
  53. Yoast_GA_Dashboards_Display::get_instance()->display( 'general' );
  54. }
  55. }
  56. else {
  57. echo '<div class="ga-promote"><p>';
  58. echo sprintf(
  59. __( 'You have not yet finished setting up Google Analytics for Wordpress by MonsterInsights. Please %sadd your Analytics profile here%s to enable tracking.', 'google-analytics-for-wordpress' ),
  60. '<a href=" ' . admin_url( 'admin.php?page=yst_ga_settings#top#general' ) . '">',
  61. '</a>'
  62. );
  63. echo '</p></div>';
  64. }
  65. ?>
  66. </div>
  67. </div>
  68. <div id="dimensions" class="wpseotab gatab">
  69. <?php
  70. if ( $tracking_code !== '' ) {
  71. if ( empty( $options['analytics_profile'] ) ) {
  72. echo '<div class="ga-promote"><p>';
  73. echo sprintf(
  74. __( 'We need you to authenticate with Google Analytics to use this functionality. If you set your UA-code manually, this won\'t work. You can %sauthenticate your Google Analytics profile here%s to enable dashboards.', 'google-analytics-for-wordpress' ),
  75. '<a href=" ' . admin_url( 'admin.php?page=yst_ga_settings#top#general' ) . '">',
  76. '</a>'
  77. );
  78. echo '</p></div>';
  79. }
  80. else if ( ! Yoast_Google_Analytics::get_instance()->has_refresh_token() ) {
  81. echo '<div class="ga-promote"><p>';
  82. echo sprintf(
  83. __( 'Because we\'ve switched to a newer version of the Google Analytics API, you\'ll need to re-authenticate with Google Analytics. We\'re sorry for the inconvenience. You can %sre-authenticate your Google Analytics profile here%s.', 'google-analytics-for-wordpress' ),
  84. '<a href=" ' . admin_url( 'admin.php?page=yst_ga_settings#top#general' ) . '">',
  85. '</a>'
  86. );
  87. echo '</p></div>';
  88. }
  89. else {
  90. ?>
  91. <div class="ga-form ga-form-input">
  92. <label class="ga-form ga-form-checkbox-label ga-form-label-left"><?php echo __( 'Select a dimension', 'google-analytics-for-wordpress' ); ?></label>
  93. </div>
  94. <select data-rel='toggle_dimensions' id="toggle_dimensions" style="width: 350px"></select>
  95. <?php
  96. Yoast_GA_Dashboards_Display::get_instance()->display( 'dimensions' );
  97. }
  98. }
  99. else {
  100. echo '<div class="ga-promote"><p>';
  101. echo sprintf(
  102. __( 'You have not yet finished setting up Google Analytics for Wordpress by MonsterInsights. Please %sadd your Analytics profile here%s to enable tracking.', 'google-analytics-for-wordpress' ),
  103. '<a href=" ' . admin_url( 'admin.php?page=yst_ga_settings#top#general' ) . '">',
  104. '</a>'
  105. );
  106. echo '</p></div>';
  107. }
  108. ?>
  109. </div>
  110. <div id="customdimensions" class="wpseotab gatab">
  111. <?php
  112. do_action( 'yst_ga_custom_dimension_add-dashboards-tab' );
  113. ?>
  114. </div>
  115. <div id="systeminfo" class="wpseotab gatab">
  116. <form action="<?php echo esc_url( admin_url( 'admin.php?page=yst_ga_dashboard#top#systeminfo' ) ); ?>" method="post" dir="ltr">
  117. <textarea id="ga-debug-info" style="width: 800px; height: 400px; font-family: Menlo, Monaco, monospace; background: none; white-space: pre; overflow: auto; display: block;" class="postbox" readonly="readonly" onclick="this.focus(); this.select()" name="monsterinsights-sysinfo" title="To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac)."><?php
  118. global $wpdb;
  119. ob_start();
  120. print_r( $this->options );
  121. $options = ob_get_contents();
  122. ob_end_clean();
  123. // Get theme info
  124. $theme_data = wp_get_theme();
  125. $theme = $theme_data->Name . ' ' . $theme_data->Version;
  126. $return = '### Begin System Info ###' . "\n\n";
  127. // Start with the basics...
  128. $return .= '-- Site Info' . "\n\n";
  129. $return .= 'Site URL: ' . site_url() . "\n";
  130. $return .= 'Home URL: ' . home_url() . "\n";
  131. $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
  132. // WordPress configuration
  133. $return .= "\n" . '-- WordPress Configuration' . "\n\n";
  134. $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
  135. $return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
  136. $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
  137. $return .= 'Active Theme: ' . $theme . "\n";
  138. $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
  139. // Only show page specs if frontpage is set to 'page'
  140. if( get_option( 'show_on_front' ) == 'page' ) {
  141. $front_page_id = get_option( 'page_on_front' );
  142. $blog_page_id = get_option( 'page_for_posts' );
  143. $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
  144. $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
  145. }
  146. $return .= 'ABSPATH: ' . ABSPATH . "\n";
  147. // Make sure wp_remote_post() is working
  148. $request['cmd'] = '_notify-validate';
  149. $params = array(
  150. 'sslverify' => false,
  151. 'timeout' => 60,
  152. 'user-agent' => 'MI/' . GAWP_VERSION,
  153. 'body' => $request
  154. );
  155. $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
  156. if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
  157. $WP_REMOTE_POST = 'wp_remote_post() works';
  158. } else {
  159. $WP_REMOTE_POST = 'wp_remote_post() does not work';
  160. }
  161. $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
  162. $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
  163. $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
  164. $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
  165. $return .= "\n" . '-- MI Version' . "\n";
  166. $return .= GAWP_VERSION;
  167. // MI configuration
  168. $return .= "\n\n" . '-- MI Configuration' . "\n";
  169. $return .= $options;
  170. // Get plugins that have an update
  171. $updates = get_plugin_updates();
  172. // Must-use plugins
  173. // NOTE: MU plugins can't show updates!
  174. $muplugins = get_mu_plugins();
  175. if( count( $muplugins > 0 ) ) {
  176. $return .= "\n" . '-- Must-Use Plugins' . "\n\n";
  177. foreach( $muplugins as $plugin => $plugin_data ) {
  178. $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
  179. }
  180. }
  181. // WordPress active plugins
  182. $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
  183. $plugins = get_plugins();
  184. $active_plugins = get_option( 'active_plugins', array() );
  185. foreach( $plugins as $plugin_path => $plugin ) {
  186. if( !in_array( $plugin_path, $active_plugins ) )
  187. continue;
  188. $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
  189. $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
  190. }
  191. // WordPress inactive plugins
  192. $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
  193. foreach( $plugins as $plugin_path => $plugin ) {
  194. if( in_array( $plugin_path, $active_plugins ) )
  195. continue;
  196. $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
  197. $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
  198. }
  199. if( is_multisite() ) {
  200. // WordPress Multisite active plugins
  201. $return .= "\n" . '-- Network Active Plugins' . "\n\n";
  202. $plugins = wp_get_active_network_plugins();
  203. $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
  204. foreach( $plugins as $plugin_path ) {
  205. $plugin_base = plugin_basename( $plugin_path );
  206. if( !array_key_exists( $plugin_base, $active_plugins ) )
  207. continue;
  208. $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
  209. $plugin = get_plugin_data( $plugin_path );
  210. $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
  211. }
  212. }
  213. // Server configuration (really just versioning)
  214. $return .= "\n" . '-- Webserver Configuration' . "\n\n";
  215. $return .= 'PHP Version: ' . PHP_VERSION . "\n";
  216. $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
  217. $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
  218. // PHP configs... now we're getting to the important stuff
  219. $return .= "\n" . '-- PHP Configuration' . "\n\n";
  220. $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
  221. $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
  222. $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
  223. $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
  224. $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
  225. $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
  226. $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
  227. $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
  228. // PHP extensions and such
  229. $return .= "\n" . '-- PHP Extensions' . "\n\n";
  230. $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
  231. $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
  232. $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
  233. $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
  234. $return .= "\n" . '### End System Info ###';
  235. echo $return;
  236. ?>
  237. </textarea>
  238. <p class="submit">
  239. <input type="hidden" name="monsterinsights-action" value="download_sysinfo" />
  240. <?php submit_button( 'Download System Info File', 'primary', 'monsterinsights-download-sysinfo', false ); ?>
  241. </p>
  242. </form>
  243. </div>
  244. </div>
  245. <?php
  246. echo $yoast_ga_admin->content_footer();
  247. ?>