/wordpress/wp-content/themes/platformpro/admin/class.debug.php

https://github.com/stonecoldtea/iona-dev · PHP · 228 lines · 169 code · 37 blank · 22 comment · 13 complexity · ab0c02c880a53590610cd4a663527c00 MD5 · raw file

  1. <?php
  2. /**
  3. *
  4. *
  5. * PageLines Debugging Information Class
  6. *
  7. *
  8. * @package Platform Framework
  9. * @subpackage Includes
  10. * @since 1.4.0
  11. *
  12. */
  13. class PageLinesDebug {
  14. // Array of debugging information
  15. var $debug_info = array();
  16. /**
  17. * PHP5 constructor
  18. * Use this to build the initial form of the object, before its manipulated by methods
  19. *
  20. */
  21. function __construct( ) {
  22. $this->wp_debug_info();
  23. }
  24. function debug_info_template(){
  25. $out = '';
  26. foreach($this->debug_info as $element ) {
  27. if ( $element['value'] ) {
  28. $out .= '<h4>'.ucfirst($element['title']).' : '. ucfirst($element['value']);
  29. $out .= (isset($element['extra'])) ? "<br /><code>{$element['extra']}</code>" : '';
  30. $out .= '</h4>';
  31. }
  32. }
  33. return $out;
  34. }
  35. // Build all the debug info into an array.
  36. function wp_debug_info(){
  37. global $wpdb, $wp_version, $platform_build;
  38. // Set data & variables first
  39. $uploads = wp_upload_dir();
  40. // Get user role
  41. $current_user = wp_get_current_user();
  42. $user_roles = $current_user->roles;
  43. $user_role = array_shift($user_roles);
  44. // Format data for processing by a template
  45. $this->debug_info[] = array(
  46. 'title' => "WordPress Version",
  47. 'value' => $wp_version,
  48. 'level' => false,
  49. );
  50. $this->debug_info[] = array(
  51. 'title' => "Multisite Enabled",
  52. 'value' => ( is_multisite() ) ? 'Yes' : 'No',
  53. 'level' => false
  54. );
  55. $this->debug_info[] = array(
  56. 'title' => "Current Role",
  57. 'value' => $user_role,
  58. 'level' => false
  59. );
  60. $this->debug_info[] = array(
  61. 'title' => "Theme Path",
  62. 'value' => '<code>' . TEMPLATEPATH . '</code>',
  63. 'level' => false
  64. );
  65. $this->debug_info[] = array(
  66. 'title' => "Theme URI",
  67. 'value' => '<code>' . get_template_directory_uri() . '</code>',
  68. 'level' => false
  69. );
  70. $this->debug_info[] = array(
  71. 'title' => "Platform Version",
  72. 'value' => CORE_VERSION,
  73. 'level' => false
  74. );
  75. $this->debug_info[] = array(
  76. 'title' => "Platform Build",
  77. 'value' => $platform_build ,
  78. 'level' => false
  79. );
  80. $this->debug_info[] = array(
  81. 'title' => "PHP Version",
  82. 'value' => floatval( phpversion() ),
  83. 'level' => false
  84. );
  85. $this->debug_info[] = array(
  86. 'title' => "Child theme",
  87. 'value' => ( TEMPLATEPATH != STYLESHEETPATH ) ? 'Yes' : '',
  88. 'level' => false,
  89. 'extra' => STYLESHEETPATH . '<br />' . get_stylesheet_directory_uri()
  90. );
  91. $this->debug_info[] = array(
  92. 'title' => "Ajax disbled",
  93. 'value' => ( get_pagelines_option( 'disable_ajax_save' ) ) ? 'Yes':'',
  94. 'level' => false
  95. );
  96. $this->debug_info[] = array(
  97. 'title' => "CSS Inline",
  98. 'value' => ( get_pagelines_option( 'inline_dynamic_css' ) ) ? 'Yes':'',
  99. 'level' => false
  100. );
  101. $this->debug_info[] = array(
  102. 'title' => "CSS Error",
  103. 'value' => ( !get_pagelines_option( 'inline_dynamic_css' ) && !is_multisite() && !is_writable( PAGELINES_DCSS ) ) ? 'File is not writable!':'',
  104. 'level' => false
  105. );
  106. $this->debug_info[] = array(
  107. 'title' => "PHP Safe Mode",
  108. 'value' => ( (bool) ini_get('safe_mode') ) ? 'Yes!':'',
  109. 'level' => false
  110. );
  111. $this->debug_info[] = array(
  112. 'title' => "PHP Open basedir restriction",
  113. 'value' => ( (bool) ini_get('open_basedir') ) ? 'Yes!':'',
  114. 'level' => false
  115. );
  116. $this->debug_info[] = array(
  117. 'title' => "PHP Register Globals",
  118. 'value' => ( (bool) ini_get('register_globals') ) ? 'Yes!':'',
  119. 'level' => false
  120. );
  121. $this->debug_info[] = array(
  122. 'title' => "PHP Magic Quotes gpc",
  123. 'value' => ( (bool) ini_get('magic_quotes_gpc') ) ? 'Yes!':'',
  124. 'level' => false
  125. );
  126. $this->debug_info[] = array(
  127. 'title' => "PHP low memory",
  128. 'value' => ( !ini_get('memory_limit') || ( intval(ini_get('memory_limit')) <= 32 ) ) ? intval(ini_get('memory_limit') ):'',
  129. 'level' => false
  130. );
  131. $this->debug_info[] = array(
  132. 'title' => "Mysql version",
  133. 'value' => ( version_compare( $wpdb->get_var("SELECT VERSION() AS version"), '5' ) < 0 ) ? $wpdb->get_var("SELECT VERSION() AS version"):'',
  134. 'level' => false
  135. );
  136. $this->debug_info[] = array(
  137. 'title' => "Upload DIR",
  138. 'value' => ( !is_writable( $uploads['path'] ) ) ? "Unable to write to <code>{$uploads['subdir']}</code>":'',
  139. 'level' => true,
  140. 'extra' => $uploads['path']
  141. );
  142. $this->debug_info[] = array(
  143. 'title' => "PHP type",
  144. 'value' => php_sapi_name(),
  145. 'level' => false
  146. );
  147. $this->debug_info[] = array(
  148. 'title' => "OS",
  149. 'value' => PHP_OS,
  150. 'level' => false
  151. );
  152. if ( get_pagelines_option('disable_updates') == true || ( is_multisite() && ! is_super_admin() ) ) {
  153. $this->debug_info[] = array(
  154. 'title' => "Automatic Updates",
  155. 'value' => 'Disabled',
  156. 'level' => false
  157. );
  158. } else {
  159. $this->debug_info[] = array(
  160. 'title' => "Updates Credentials",
  161. 'value' => ( !pagelines_option( 'lp_username' ) || !pagelines_option( 'lp_password' ) ) ? 'Username/Password is required for automatic upgrades to function.' : '',
  162. 'level' => false
  163. );
  164. if ( is_array( $a = get_transient('pagelines-update-PlatformPro') ) ) {
  165. $this->debug_info[] = array(
  166. 'title' => "Automatic Updates",
  167. 'value' => ( $a['package'] !== 'bad' ) ? 'Working.' : 'Not working',
  168. 'extra' => ( $a['package'] !== 'bad' ) ? 'Latest available: ' . array_shift( array_splice( $a, 0, count( $a ) ) ) : '',
  169. 'level' => false
  170. );
  171. }
  172. }
  173. $this->debug_info[] = array(
  174. 'title' => "Plugins",
  175. 'value' => $this->debug_get_plugins(),
  176. 'level' => false
  177. );
  178. }
  179. function debug_get_plugins() {
  180. $plugins = get_option('active_plugins');
  181. if ( $plugins ) {
  182. $plugins_list = '';
  183. foreach($plugins as $plugin_file) {
  184. $plugins_list .= '<code>' . $plugin_file . '</code>';
  185. $plugins_list .= '<br />';
  186. }
  187. return ( isset( $plugins_list ) ) ? count($plugins) . "<br />{$plugins_list}" : '';
  188. }
  189. }
  190. //-------- END OF CLASS --------//
  191. }