CPTUI_Debug_Info

Custom Post Type UI Debug Info.

Defined (1)

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

/classes/class.cptui_debug_info.php  
  1. class CPTUI_Debug_Info { 
  2.  
  3. /** 
  4. * Tab content for the debug info tab. 
  5. * @since 1.2.0 
  6. */ 
  7. public function tab_site_info() { 
  8. ?> 
  9. <p><?php _e( 'If you have sought support for Custom Post Type UI on the forums, you may be requested to send the information below to the plugin developer. Simply insert the email they provided in the input field at the bottom and click the "Send debug info" button. Only the data below will be sent to them.', 'custom-post-type-ui' ); ?></p> 
  10. <label for="cptui_audit_textarea"> 
  11. <textarea readonly="readonly" aria-readonly="true" id="cptui-audit-textarea" name="cptui_audit_textarea" rows="20" cols="100"> 
  12. <?php echo $this->system_status(); ?> 
  13. </textarea></label> 
  14. <?php 
  15.  
  16. /** 
  17. * Generate the debug information content. 
  18. * @since 1.2.0 
  19. * @return string 
  20. */ 
  21. private function system_status() { 
  22. if ( ! current_user_can( 'manage_options' ) ) { 
  23. return ''; 
  24.  
  25. global $wpdb; 
  26.  
  27. $theme_data = wp_get_theme(); 
  28. $theme = $theme_data->Name . ' ' . $theme_data->Version; 
  29.  
  30. ob_start(); 
  31. ?> 
  32.  
  33. ### Begin Custom Post Type UI Debug Info ### 
  34.  
  35. Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?> 
  36.  
  37. SITE_URL: <?php echo site_url() . "\n"; ?> 
  38. HOME_URL: <?php echo home_url() . "\n"; ?> 
  39.  
  40. WordPress Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?> 
  41. Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?> 
  42. Active Theme: <?php echo $theme . "\n"; ?> 
  43.  
  44. Registered Post Types: <?php echo implode( ', ', get_post_types( '', 'names' ) ) . "\n"; ?> 
  45.  
  46. PHP Version: <?php echo PHP_VERSION . "\n"; ?> 
  47. MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?> 
  48. Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?> 
  49.  
  50. Show On Front: <?php echo get_option( 'show_on_front' ) . "\n" ?> 
  51. Page On Front: <?php $id = get_option( 'page_on_front' ); 
  52. echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?> 
  53. Page For Posts: <?php $id = get_option( 'page_for_posts' ); 
  54. echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?> 
  55.  
  56. WordPress Memory Limit: <?php echo ( $this->num_convt( WP_MEMORY_LIMIT ) / ( 1024 ) ) . 'MB'; ?><?php echo "\n"; ?> 
  57.  
  58. <?php 
  59. $plugins = get_plugins(); 
  60. $pg_count = count( $plugins ); 
  61. echo 'TOTAL PLUGINS: ' . $pg_count . "\n\n"; 
  62. // MU plugins. 
  63. $mu_plugins = get_mu_plugins(); 
  64.  
  65. if ( $mu_plugins ) : 
  66. echo "\t\t" . 'MU PLUGINS: (' . count( $mu_plugins ) . ')' . "\n\n"; 
  67.  
  68. foreach ( $mu_plugins as $mu_path => $mu_plugin ) { 
  69.  
  70. echo "\t\t" . $mu_plugin['Name'] . ': ' . $mu_plugin['Version'] . "\n"; 
  71. endif; 
  72. // Standard plugins - active. 
  73. echo "\n"; 
  74.  
  75. $active = get_option( 'active_plugins', array() ); 
  76. $ac_count = count( $active ); 
  77. $ic_count = $pg_count - $ac_count; 
  78.  
  79. echo "\t\t" . 'ACTIVE PLUGINS: (' . $ac_count . ')' . "\n\n"; 
  80.  
  81. foreach ( $plugins as $plugin_path => $plugin ) { 
  82. // If the plugin isn't active, don't show it. 
  83. if ( ! in_array( $plugin_path, $active ) ) { 
  84. continue; 
  85.  
  86. echo "\t\t" . $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; 
  87. // Standard plugins - inactive. 
  88. echo "\n"; 
  89. echo "\t\t" , 'INACTIVE PLUGINS: (' . $ic_count . ')' . "\n\n"; 
  90.  
  91. foreach ( $plugins as $plugin_path => $plugin ) { 
  92. // If the plugin isn't active, show it here. 
  93. if ( in_array( $plugin_path, $active ) ) { 
  94. continue; 
  95.  
  96. echo "\t\t" . $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; 
  97.  
  98. // If multisite, grab network as well. 
  99. if ( is_multisite() ) : 
  100.  
  101. $net_plugins = wp_get_active_network_plugins(); 
  102. $net_active = get_site_option( 'active_sitewide_plugins', array() ); 
  103.  
  104. echo "\n"; 
  105. echo 'NETWORK ACTIVE PLUGINS: (' . count( $net_plugins ) . ')' . "\n\n"; 
  106.  
  107. foreach ( $net_plugins as $plugin_path ) { 
  108. $plugin_base = plugin_basename( $plugin_path ); 
  109.  
  110. // If the plugin isn't active, don't show it. 
  111. if ( ! array_key_exists( $plugin_base, $net_active ) ) { 
  112. continue; 
  113.  
  114. $plugin = get_plugin_data( $plugin_path ); 
  115.  
  116. echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n"; 
  117.  
  118. endif; 
  119.  
  120. echo "\n"; 
  121. $cptui_post_types = cptui_get_post_type_data(); 
  122. echo "\t\t" . 'Post Types: ' . "\n"; 
  123. echo "\t\t" . esc_html( json_encode( $cptui_post_types ) ) . "\n"; 
  124.  
  125. echo "\n\n"; 
  126.  
  127. $cptui_taxonomies = cptui_get_taxonomy_data(); 
  128. echo "\t\t" . 'Taxonomies: ' . "\n"; 
  129. echo "\t\t" . esc_html( json_encode( $cptui_taxonomies ) ) . "\n"; 
  130. echo "\n"; 
  131.  
  132. if ( has_action( 'cptui_custom_debug_info' ) ) { 
  133. echo "\t\t" . 'EXTRA DEBUG INFO'; 
  134.  
  135. /** 
  136. * Fires at the end of the debug info output. 
  137. * @since 1.3.0 
  138. */ 
  139. do_action( 'cptui_custom_debug_info' ); 
  140.  
  141. echo "\n"; 
  142. ?> 
  143. ### End Debug Info ### 
  144. <?php 
  145.  
  146. return ob_get_clean(); 
  147.  
  148. /** 
  149. * Helper function for number conversions. 
  150. * @since 1.2.0 
  151. * @access public 
  152. * @param mixed $v Value. 
  153. * @return int 
  154. */ 
  155. public function num_convt( $v ) { 
  156. $l = substr( $v, - 1 ); 
  157. $ret = substr( $v, 0, - 1 ); 
  158.  
  159. switch ( strtoupper( $l ) ) { 
  160. case 'P': // Fall-through. 
  161. case 'T': // Fall-through. 
  162. case 'G': // Fall-through. 
  163. case 'M': // Fall-through. 
  164. case 'K': // Fall-through. 
  165. $ret *= 1024; 
  166. break; 
  167. default: 
  168. break; 
  169.  
  170. return $ret; 
  171.  
  172. /** 
  173. * Sends an email to the specified address, with the system status as the message. 
  174. * @since 1.2.0 
  175. * @param array $args Array of arguments for the method. Optional. 
  176. * @return bool 
  177. */ 
  178. public function send_email( $args = array() ) { 
  179.  
  180. if ( ! isset( $args['email'] ) || ! is_email( $args['email'] ) ) { 
  181. return false; 
  182.  
  183. stripslashes_deep( $args ); 
  184.  
  185. $args['email'] = sanitize_email( $args['email'] ); 
  186.  
  187. $message = $this->system_status(); 
  188.  
  189. /** 
  190. * Filters the debug email subject. 
  191. * @since 1.3.0 
  192. * @param string $value Intended email subject. 
  193. */ 
  194. $subject = apply_filters( 'cptui_debug_email_subject', sprintf( 
  195. __( 'CPTUI debug information for %s', 'custom-post-type-ui' ),  
  196. home_url( '/' ) 
  197. ) ); 
  198.  
  199. $result = wp_mail( $args['email'], $subject, $message ); 
  200.  
  201. /** 
  202. * Fires after the debug email has been sent. 
  203. * @since 1.3.0 
  204. */ 
  205. do_action( 'cptui_after_debug_email_sent' ); 
  206.  
  207. return $result;