cf7style_system_status

CF7 Style System status.

Description

cf7style_system_status(); 

Usage

  1. if ( !function_exists( 'cf7style_system_status' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7-style/inc/system_status.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = cf7style_system_status(); 
  7.  

Defined (1)

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

/inc/system_status.php  
  1. function cf7style_system_status() { 
  2.  
  3. /** 
  4. * let_to_num function. 
  5. * This function transforms the php.ini notation for numbers (like '2M') to an integer. 
  6. * @param $size 
  7. * @return int 
  8. */ 
  9. function cf7style_let_to_num( $size ) { 
  10. $l = substr( $size, -1 ); 
  11. $ret = substr( $size, 0, -1 ); 
  12. switch ( strtoupper( $l ) ) { 
  13. case 'P': 
  14. $ret *= 1024; 
  15. case 'T': 
  16. $ret *= 1024; 
  17. case 'G': 
  18. $ret *= 1024; 
  19. case 'M': 
  20. $ret *= 1024; 
  21. case 'K': 
  22. $ret *= 1024; 
  23. return $ret; 
  24.  
  25.  
  26. // Cache variables 
  27. $html = ''; 
  28. $table = ''; 
  29. $form = ''; 
  30. $table_start = '<table class="wp-list-table widefat striped cf7style-status-table">'; 
  31. $table_end = '</table><small> </small>'; 
  32.  
  33. $html .= '<div class="wrap">'; 
  34. $html .= '<h2>' . __( "System Status", "contact-form-7-style" ) . '</h2>'; 
  35. $html .= '<p>' . __( "The Contact Form 7 Style System Status is a tool for troubleshooting issues with your site.", "contact-form-7-style" ) . '</p>'; 
  36. $html .= '<p>' . __( "With the informations gathered from you we can debug and analyze and try to offer you a fix.", "contact-form-7-style" ) . '</p>'; 
  37. $html .= '<p>' . __( "The System Status is the best way for Contact Form 7 Style Support to help you!", "contact-form-7-style" ) . '</p>'; 
  38.  
  39. // Form 
  40. $form .= '<form class="cf7style-status-form">'; 
  41. $form .= '<p><input type="text" name="cf7style-name" class="cf7style-name cf7style-input" placeholder="' . __( "Your name", "contact-form-7-style" ) .'" /></p>'; 
  42. $form .= '<p><input type="email" name="cf7style-email" class="cf7style-email cf7style-input" placeholder="' . __( "Your email", "contact-form-7-style" ) .'" /></p>'; 
  43. $form .= '<p><textarea name="cf7style-message" class="cf7style-message cf7style-input" placeholder="' . __( "Your message", "cf7style-message", "contact-form-7-style" ) . '"></textarea></p>'; 
  44. $form .= '<button class="button cf7style-status-info">' . __( "Show the environment report", "contact-form-7-style" ) . '</button>'; 
  45.  
  46. // Debug - system status send button 
  47. //delete_transient( 'cf7style_system_report' ); 
  48.  
  49. $report_status = get_transient( 'cf7style_system_report' ); 
  50.  
  51. if( $report_status && 'sent' == $report_status ) { 
  52. $form .= '<button class="button-primary" disabled="disabled">' . __( "Report sent", "contact-form-7-style" ) . '</button>'; 
  53. } else { 
  54. $form .= '<button class="button-primary cf7style-status-submit">' . __( "I think I have a CF7 Style issue. Send Report to CF7 Style Support team.", "contact-form-7-style" ) . '</button>'; 
  55.  
  56. $form .= '</form>'; 
  57.  
  58. $html .= $form; 
  59.  
  60. // General 
  61. $table .= $table_start; 
  62. $table .= '<thead><tr><th colspan="2"><strong>' . __( "Your WordPress Setup", "contact-form-7-style" ) . '</strong></th></tr></thead>';  
  63.  
  64. // Home URL 
  65. $table .= "<tr><td>" . __( 'Home URL:', 'contact-form-7-style' ) . "</td>"; 
  66. $table .= "<td>" . home_url() . "</td></tr>"; 
  67.  
  68. // Site URL 
  69. $table .= "<tr><td>" . __( 'Site URL:', 'contact-form-7-style' ) . "</td>"; 
  70. $table .= "<td>" . site_url() . "</td></tr>"; 
  71.  
  72. // CF7 Style Version 
  73. $table .= "<tr><td>" . __( 'Contact Form 7 Style Version:', 'contact-form-7-style' ) . "</td>"; 
  74. $table .= "<td>" . WPCF7S_PLUGIN_VER . "</td></tr>"; 
  75.  
  76. // WP Version 
  77. $table .= "<tr><td>" . __( 'WP Version:', 'contact-form-7-style' ) . "</td>"; 
  78. $table .= "<td>" . get_bloginfo( 'version' ) . "</td></tr>";  
  79.  
  80. // WP Multisite 
  81. $table .= "<tr><td>" . __( 'WP Multisite:', 'contact-form-7-style' ) . "</td>"; 
  82. $table .= "<td>" . ( ( is_multisite() ) ? "Yes" : "No" ) . "</td></tr>"; 
  83.  
  84. // WP Memory Limit 
  85. $memory = cf7style_let_to_num( WP_MEMORY_LIMIT ); 
  86. $table .= "<tr><td>" . __( ' WP Memory Limit:', 'contact-form-7-style' ) . "</td>"; 
  87.  
  88. if ( $memory < 100663296 ) { 
  89. $table .= '<td><mark class="error">' . sprintf( __( '%s - Recommended memory at least 96MB. See: <a href="%s" target="_blank">Increasing memory allocated to PHP</a>', 'contact-form-7-style' ), size_format( $memory ), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . '</mark></td></tr>'; 
  90. } else { 
  91. $table .= '<td><mark class="yes">' . size_format( $memory ) . '</mark></td></tr>'; 
  92.  
  93. // WP Debug Mode 
  94. $table .= "<tr><td>" . __( 'WP Debug Mode:', 'contact-form-7-style' ) . "</td>"; 
  95. $table .= "<td>" . ( ( WP_DEBUG ) ? "enabled" : "disabled" ) . "</td></tr>";  
  96.  
  97. // Language 
  98. $table .= "<tr><td>" . __( 'Language:', 'contact-form-7-style' ) . "</td>"; 
  99. $table .= "<td>" . get_locale() . "</td></tr>";  
  100.  
  101. // Email address for feedback 
  102. $table .= "<tr><td>" . __( 'Site email address', 'contact-form-7-style' ) . "</td>"; 
  103. $table .= "<td>" . get_option( 'admin_email' ) . "</td></tr>"; 
  104.  
  105. $table .= $table_end; 
  106.  
  107.  
  108. // Your Server Setup 
  109. $table .= $table_start; 
  110. $table .= '<thead><tr><th colspan="2"><strong>' . __( "Your Server Setup", "contact-form-7-style" ) . '</strong></th></tr></thead>';  
  111.  
  112. // Server info 
  113. $table .= "<tr><td>" . __( 'Server info', 'contact-form-7-style' ) . "</td>"; 
  114. $table .= "<td>" . esc_html( $_SERVER['SERVER_SOFTWARE'] ) . "</td></tr>"; 
  115.  
  116. // PHP version 
  117. $table .= "<tr><td>" . __( 'PHP Version', 'contact-form-7-style' ) . "</td>"; 
  118. if ( function_exists( 'phpversion' ) ) : 
  119.  
  120. $php_version = phpversion(); 
  121.  
  122. if ( version_compare( $php_version, '5.6', '<' ) ) { 
  123. $table .= '<td><mark class="error">' . sprintf( __( '%s - WordPress recommends a minimum PHP version of 5.6. See: %s', 'contact-form-7-style' ), esc_html( $php_version ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . __( 'WordPress Requirements', 'contact-form-7-style' ) . '</a>' ) . '</mark></td></tr>'; 
  124. } else { 
  125. $table .= '<td><mark class="yes">' . esc_html( $php_version ) . '</mark></td></tr>'; 
  126. else : 
  127. $table .= '<td>' . __( "Couldn't determine PHP version because phpversion() doesn't exist.", 'contact-form-7-style' ) . '</td></tr>'; 
  128. endif; 
  129.  
  130. if ( function_exists( 'ini_get' ) ) : 
  131.  
  132. // PHP Post Max Size 
  133. $table .= "<tr><td>" . __( 'PHP Post Max Size:', 'contact-form-7-style' ) . "</td>"; 
  134. $table .= "<td>" . size_format( cf7style_let_to_num( ini_get( 'post_max_size' ) ) ) . "</td></tr>"; 
  135.  
  136. endif; 
  137.  
  138. // MySQL Version 
  139.  
  140. /** @global wpdb $wpdb */ 
  141. global $wpdb; 
  142.  
  143. $table .= "<tr><td>" . __( 'MySQL Version:', 'contact-form-7-style' ) . "</td>"; 
  144. $table .= "<td>" . $wpdb->db_version() . "</td></tr>"; 
  145.  
  146. // Max Upload Size 
  147. $table .= "<tr><td>" . __( 'Max Upload Size', 'contact-form-7-style' ) . "</td>"; 
  148. $table .= "<td>" . size_format( wp_max_upload_size() ) . "</td></tr>"; 
  149.  
  150. // Default Timezone 
  151. $default_timezone = date_default_timezone_get(); 
  152.  
  153. $table .= "<tr><td>" . __( 'Default Timezone:', 'contact-form-7-style' ) . "</td>"; 
  154. $table .= '<td>' . $default_timezone . '</td></tr>'; 
  155.  
  156. $table .= $table_end; 
  157.  
  158.  
  159. // Active Plugins 
  160. $active_plugins_count = count( (array) get_option( 'active_plugins' ) ); 
  161.  
  162. $table .= $table_start; 
  163. $table .= '<thead><tr><th colspan="2"><strong>' . __( "Active Plugins", "contact-form-7-style" ) . ' (' . $active_plugins_count . ')</strong></th></tr></thead>'; 
  164.  
  165. $active_plugins = (array) get_option( 'active_plugins', array() ); 
  166.  
  167. if ( is_multisite() ) { 
  168. $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); 
  169. $active_plugins = array_merge( $active_plugins, $network_activated_plugins ); 
  170.  
  171. foreach ( $active_plugins as $plugin ) { 
  172.  
  173. $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 
  174. $dirname = dirname( $plugin ); 
  175. $version_string = ''; 
  176. $network_string = ''; 
  177.  
  178. if ( ! empty( $plugin_data['Name'] ) ) { 
  179.  
  180. // Link the plugin name to the plugin url if available. 
  181. $plugin_name = esc_html( $plugin_data['Name'] ); 
  182.  
  183. if ( ! empty( $plugin_data['PluginURI'] ) ) { 
  184. $plugin_name = '<a href="' . esc_url( $plugin_data['PluginURI'] ) . '" title="' . esc_attr__( 'Visit plugin homepage' , 'contact-form-7-style' ) . '" target="_blank">' . $plugin_name . '</a>'; 
  185.  
  186. $table .= "<tr><td>" . $plugin_name. "</td>"; 
  187. $table .= "<td>" . sprintf( _x( 'by %s', 'by author', 'contact-form-7-style' ), $plugin_data['Author'] ) . ' – ' . __( 'Version', 'contact-form-7-style' ) . ' ' . esc_html( $plugin_data['Version'] ) . $version_string . $network_string . "</td></tr>";  
  188.  
  189. }  
  190.  
  191.  
  192. $table .= $table_end; 
  193.  
  194.  
  195. // Active Theme 
  196. $active_theme = wp_get_theme();  
  197.  
  198. $table .= $table_start; 
  199. $table .= '<thead><tr><th colspan="2"><strong>' . __( "Theme", "contact-form-7-style" ) . '</strong></th></tr></thead>'; 
  200.  
  201. $table .= "<tr><td>" . __( 'Name:', 'contact-form-7-style' ) . "</td>"; 
  202. $table .= "<td>" . $active_theme->Name . "</td></tr>"; 
  203.  
  204. $table .= "<tr><td>" . __( 'Version:', 'contact-form-7-style' ) . "</td>"; 
  205. $table .= "<td>" . $active_theme->Version . "</td></tr>"; 
  206.  
  207. $table .= "<tr><td>" . __( 'Child Theme:', 'contact-form-7-style' ) . "</td>"; 
  208. $table .= "<td>" . ( ( is_child_theme() ) ? 'Yes' : 'No' ) . "</td></tr>"; 
  209.  
  210. $table .= "<tr><td>" . __( 'Theme URL:', 'contact-form-7-style' ) . "</td>"; 
  211. $table .= "<td>" . $active_theme->get( 'ThemeURI' ) . "</td></tr>"; 
  212.  
  213. $table .= $table_end; 
  214.  
  215. $html .= $table; 
  216. $html .= '</div>'; 
  217.  
  218. echo $html;