All_in_One_SEO_Pack_Performance

The All In One SEO Pack All in One SEO Pack Performance class.

Defined (1)

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

/modules/aioseop_performance.php  
  1. class All_in_One_SEO_Pack_Performance extends All_in_One_SEO_Pack_Module { 
  2.  
  3. protected $module_info = array(); 
  4.  
  5. function __construct( $mod ) { 
  6. $this->name = __( 'Performance', 'all-in-one-seo-pack' ); // Human-readable name of the plugin. 
  7. $this->prefix = 'aiosp_performance_'; // Option prefix. 
  8. $this->file = __FILE__; // The current file. 
  9. parent::__construct(); 
  10.  
  11. $this->help_text = array( 
  12. 'memory_limit' => __( 'This setting allows you to raise your PHP memory limit to a reasonable value. Note: WordPress core and other WordPress plugins may also change the value of the memory limit.', 'all-in-one-seo-pack' ),  
  13. 'execution_time' => __( 'This setting allows you to raise your PHP execution time to a reasonable value.', 'all-in-one-seo-pack' ),  
  14. 'force_rewrites' => __( 'Use output buffering to ensure that the title gets rewritten. Enable this option if you run into issues with the title tag being set by your theme or another plugin.', 'all-in-one-seo-pack' ),  
  15. ); 
  16.  
  17. $this->default_options = array( 
  18. 'memory_limit' => array( 
  19. 'name' => __( 'Raise memory limit', 'all-in-one-seo-pack' ),  
  20. 'default' => '256M',  
  21. 'type' => 'select',  
  22. 'initial_options' => array( 
  23. 0 => __( 'Use the system default', 'all-in-one-seo-pack' ),  
  24. '32M' => '32MB',  
  25. '64M' => '64MB',  
  26. '128M' => '128MB',  
  27. '256M' => '256MB',  
  28. ),  
  29. ),  
  30. 'execution_time' => array( 
  31. 'name' => __( 'Raise execution time', 'all-in-one-seo-pack' ),  
  32. 'default' => '',  
  33. 'type' => 'select',  
  34. 'initial_options' => array( 
  35. '' => __( 'Use the system default', 'all-in-one-seo-pack' ),  
  36. 30 => '30s',  
  37. 60 => '1m',  
  38. 120 => '2m',  
  39. 300 => '5m',  
  40. 0 => __( 'No limit', 'all-in-one-seo-pack' ),  
  41. ),  
  42. ),  
  43. ); 
  44.  
  45. $this->help_anchors = array( 
  46. 'memory_limit' => '#raise-memory-limit',  
  47. 'execution_time' => '#raise-execution-time',  
  48. 'force_rewrites' => '#force-rewrites',  
  49. ); 
  50.  
  51. global $aiosp, $aioseop_options; 
  52. if ( aioseop_option_isset( 'aiosp_rewrite_titles' ) && $aioseop_options['aiosp_rewrite_titles'] ) { 
  53. $this->default_options['force_rewrites'] = array( 
  54. 'name' => __( 'Force Rewrites:', 'all-in-one-seo-pack' ),  
  55. 'default' => 1,  
  56. 'type' => 'radio',  
  57. 'initial_options' => array( 
  58. 1 => __( 'Enabled', 'all-in-one-seo-pack' ),  
  59. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  60. ),  
  61. ); 
  62.  
  63. $this->layout = array( 
  64. 'default' => array( 
  65. 'name' => $this->name,  
  66. 'help_link' => 'http://semperplugins.com/documentation/performance-settings/',  
  67. 'options' => array_keys( $this->default_options ),  
  68. ),  
  69. ); 
  70.  
  71. $system_status = array( 
  72. 'status' => array( 'default' => '', 'type' => 'html', 'label' => 'none', 'save' => false ),  
  73. ); 
  74.  
  75. $this->layout['system_status'] = array( 
  76. 'name' => __( 'System Status', 'all-in-one-seo-pack' ),  
  77. 'help_link' => 'http://semperplugins.com/documentation/performance-settings/',  
  78. 'options' => array_keys( $system_status ),  
  79. ); 
  80.  
  81. $this->default_options = array_merge( $this->default_options, $system_status ); 
  82.  
  83. $this->add_help_text_links(); 
  84.  
  85. add_filter( $this->prefix . 'display_options', array( $this, 'display_options_filter' ), 10, 2 ); 
  86. add_filter( $this->prefix . 'update_options', array( $this, 'update_options_filter' ), 10, 2 ); 
  87. add_action( $this->prefix . 'settings_update', array( $this, 'settings_update_action' ), 10, 2 ); 
  88.  
  89. function update_options_filter( $options, $location ) { 
  90. if ( $location == null && isset( $options[ $this->prefix . 'force_rewrites' ] ) ) { 
  91. unset( $options[ $this->prefix . 'force_rewrites' ] ); 
  92.  
  93. return $options; 
  94.  
  95. function display_options_filter( $options, $location ) { 
  96. if ( $location == null ) { 
  97. $options[ $this->prefix . 'force_rewrites' ] = 1; 
  98. global $aiosp; 
  99. if ( aioseop_option_isset( 'aiosp_rewrite_titles' ) ) { 
  100. $opts = $aiosp->get_current_options( array(), null ); 
  101. $options[ $this->prefix . 'force_rewrites' ] = $opts['aiosp_force_rewrites']; 
  102.  
  103. return $options; 
  104.  
  105. function settings_update_action( $options, $location ) { 
  106. if ( $location == null && isset( $_POST[ $this->prefix . 'force_rewrites' ] ) ) { 
  107. $force_rewrites = $_POST[ $this->prefix . 'force_rewrites' ]; 
  108. if ( ( $force_rewrites == 0 ) || ( $force_rewrites == 1 ) ) { 
  109. global $aiosp; 
  110. $opts = $aiosp->get_current_options( array(), null ); 
  111. $opts['aiosp_force_rewrites'] = $force_rewrites; 
  112. $aiosp->update_class_option( $opts ); 
  113. wp_cache_flush(); 
  114.  
  115. function add_page_hooks() { 
  116. $memory_usage = memory_get_peak_usage() / 1024 / 1024; 
  117. if ( $memory_usage > 32 ) { 
  118. unset( $this->default_options['memory_limit']['initial_options']['32M'] ); 
  119. if ( $memory_usage > 64 ) { 
  120. unset( $this->default_options['memory_limit']['initial_options']['64M'] ); 
  121. if ( $memory_usage > 128 ) { 
  122. unset( $this->default_options['memory_limit']['initial_options']['128M'] ); 
  123. if ( $memory_usage > 256 ) { 
  124. unset( $this->default_options['memory_limit']['initial_options']['256M'] ); 
  125. $this->update_options(); 
  126. parent::add_page_hooks(); 
  127.  
  128. function settings_page_init() { 
  129. $this->default_options['status']['default'] = $this->get_serverinfo(); 
  130.  
  131. function menu_order() { 
  132. return 7; 
  133.  
  134. function get_serverinfo() { 
  135. global $wpdb; 
  136. global $wp_version; 
  137.  
  138. $sqlversion = $wpdb->get_var( "SELECT VERSION() AS version" ); 
  139. $mysqlinfo = $wpdb->get_results( "SHOW VARIABLES LIKE 'sql_mode'" ); 
  140. if ( is_array( $mysqlinfo ) ) { 
  141. $sql_mode = $mysqlinfo[0]->Value; 
  142. if ( empty( $sql_mode ) ) { 
  143. $sql_mode = __( 'Not set', 'all-in-one-seo-pack' ); 
  144. if ( ini_get( 'allow_url_fopen' ) ) { 
  145. $allow_url_fopen = __( 'On', 'all-in-one-seo-pack' ); 
  146. } else { 
  147. $allow_url_fopen = __( 'Off', 'all-in-one-seo-pack' ); 
  148. if ( ini_get( 'upload_max_filesize' ) ) { 
  149. $upload_max = ini_get( 'upload_max_filesize' ); 
  150. } else { 
  151. $upload_max = __( 'N/A', 'all-in-one-seo-pack' ); 
  152. if ( ini_get( 'post_max_size' ) ) { 
  153. $post_max = ini_get( 'post_max_size' ); 
  154. } else { 
  155. $post_max = __( 'N/A', 'all-in-one-seo-pack' ); 
  156. if ( ini_get( 'max_execution_time' ) ) { 
  157. $max_execute = ini_get( 'max_execution_time' ); 
  158. } else { 
  159. $max_execute = __( 'N/A', 'all-in-one-seo-pack' ); 
  160. if ( ini_get( 'memory_limit' ) ) { 
  161. $memory_limit = ini_get( 'memory_limit' ); 
  162. } else { 
  163. $memory_limit = __( 'N/A', 'all-in-one-seo-pack' ); 
  164. if ( function_exists( 'memory_get_usage' ) ) { 
  165. $memory_usage = round( memory_get_usage() / 1024 / 1024, 2 ) . __( ' MByte', 'all-in-one-seo-pack' ); 
  166. } else { 
  167. $memory_usage = __( 'N/A', 'all-in-one-seo-pack' ); 
  168. if ( is_callable( 'exif_read_data' ) ) { 
  169. $exif = __( 'Yes', 'all-in-one-seo-pack' ) . ' ( V' . $this->substr( phpversion( 'exif' ), 0, 4 ) . ')'; 
  170. } else { 
  171. $exif = __( 'No', 'all-in-one-seo-pack' ); 
  172. if ( is_callable( 'iptcparse' ) ) { 
  173. $iptc = __( 'Yes', 'all-in-one-seo-pack' ); 
  174. } else { 
  175. $iptc = __( 'No', 'all-in-one-seo-pack' ); 
  176. if ( is_callable( 'xml_parser_create' ) ) { 
  177. $xml = __( 'Yes', 'all-in-one-seo-pack' ); 
  178. } else { 
  179. $xml = __( 'No', 'all-in-one-seo-pack' ); 
  180.  
  181. $theme = wp_get_theme(); 
  182.  
  183. if ( function_exists( 'is_multisite' ) ) { 
  184. if ( is_multisite() ) { 
  185. $ms = __( 'Yes', 'all-in-one-seo-pack' ); 
  186. } else { 
  187. $ms = __( 'No', 'all-in-one-seo-pack' ); 
  188.  
  189. } else { 
  190. $ms = __( 'N/A', 'all-in-one-seo-pack' ); 
  191.  
  192. $siteurl = get_option( 'siteurl' ); 
  193. $homeurl = get_option( 'home' ); 
  194. $db_version = get_option( 'db_version' ); 
  195.  
  196. $debug_info = array( 
  197. __( 'Operating System', 'all-in-one-seo-pack' ) => PHP_OS,  
  198. __( 'Server', 'all-in-one-seo-pack' ) => $_SERVER['SERVER_SOFTWARE'],  
  199. __( 'Memory usage', 'all-in-one-seo-pack' ) => $memory_usage,  
  200. __( 'MYSQL Version', 'all-in-one-seo-pack' ) => $sqlversion,  
  201. __( 'SQL Mode', 'all-in-one-seo-pack' ) => $sql_mode,  
  202. __( 'PHP Version', 'all-in-one-seo-pack' ) => PHP_VERSION,  
  203. __( 'PHP Allow URL fopen', 'all-in-one-seo-pack' ) => $allow_url_fopen,  
  204. __( 'PHP Memory Limit', 'all-in-one-seo-pack' ) => $memory_limit,  
  205. __( 'PHP Max Upload Size', 'all-in-one-seo-pack' ) => $upload_max,  
  206. __( 'PHP Max Post Size', 'all-in-one-seo-pack' ) => $post_max,  
  207. __( 'PHP Max Script Execute Time', 'all-in-one-seo-pack' ) => $max_execute,  
  208. __( 'PHP Exif support', 'all-in-one-seo-pack' ) => $exif,  
  209. __( 'PHP IPTC support', 'all-in-one-seo-pack' ) => $iptc,  
  210. __( 'PHP XML support', 'all-in-one-seo-pack' ) => $xml,  
  211. __( 'Site URL', 'all-in-one-seo-pack' ) => $siteurl,  
  212. __( 'Home URL', 'all-in-one-seo-pack' ) => $homeurl,  
  213. __( 'WordPress Version', 'all-in-one-seo-pack' ) => $wp_version,  
  214. __( 'WordPress DB Version', 'all-in-one-seo-pack' ) => $db_version,  
  215. __( 'Multisite', 'all-in-one-seo-pack' ) => $ms,  
  216. __( 'Active Theme', 'all-in-one-seo-pack' ) => $theme['Name'] . ' ' . $theme['Version'],  
  217. ); 
  218. $debug_info['Active Plugins'] = null; 
  219. $active_plugins = $inactive_plugins = array(); 
  220. $plugins = get_plugins(); 
  221. foreach ( $plugins as $path => $plugin ) { 
  222. if ( is_plugin_active( $path ) ) { 
  223. $debug_info[ $plugin['Name'] ] = $plugin['Version']; 
  224. } else { 
  225. $inactive_plugins[ $plugin['Name'] ] = $plugin['Version']; 
  226. $debug_info['Inactive Plugins'] = null; 
  227. $debug_info = array_merge( $debug_info, (array) $inactive_plugins ); 
  228.  
  229. $mail_text = __( 'All in One SEO Pack Pro Debug Info', 'all-in-one-seo-pack' ) . "\r\n------------------\r\n\r\n"; 
  230. $page_text = ''; 
  231. if ( ! empty( $debug_info ) ) { 
  232. foreach ( $debug_info as $name => $value ) { 
  233. if ( $value !== null ) { 
  234. $page_text .= "<li><strong>$name</strong> $value</li>"; 
  235. $mail_text .= "$name: $value\r\n"; 
  236. } else { 
  237. $page_text .= "</ul><h2>$name</h2><ul class='sfwd_debug_settings'>"; 
  238. $mail_text .= "\r\n$name\r\n----------\r\n"; 
  239.  
  240. do { 
  241. if ( ! empty( $_REQUEST['sfwd_debug_submit'] ) || ! empty( $_REQUEST['sfwd_update_check'] ) ) { 
  242. $nonce = $_REQUEST['sfwd_debug_nonce']; 
  243. if ( ! wp_verify_nonce( $nonce, 'sfwd-debug-nonce' ) ) { 
  244. echo "<div class='sfwd_debug_error'>" . __( 'Form submission error: verification check failed.', 'all-in-one-seo-pack' ) . '</div>'; 
  245. break; 
  246. if ( $_REQUEST['sfwd_update_check'] ) { 
  247. global $aioseop_update_checker; 
  248. $aioseop_update_checker->checkForUpdates(); 
  249. echo "<div class='sfwd_debug_mail_sent'>" . sprintf( __( '%s has checked for updates.', 'all-in-one-seo-pack' ), AIOSEOP_PLUGIN_NAME ) . '</div>'; 
  250. break; 
  251. $email = ''; 
  252. if ( ! empty( $_REQUEST['sfwd_debug_send_email'] ) ) { 
  253. $email = sanitize_email( $_REQUEST['sfwd_debug_send_email'] ); 
  254. if ( $email ) { 
  255. if ( wp_mail( $email, sprintf( __( 'SFWD Debug Mail From Site %s.', 'all-in-one-seo-pack' ), $siteurl ), $mail_text ) ) { 
  256. echo "<div class='sfwd_debug_mail_sent'>" . sprintf( __( 'Sent to %s.', 'all-in-one-seo-pack' ), $email ) . '</div>'; 
  257. } else { 
  258. echo "<div class='sfwd_debug_error'>" . sprintf( __( 'Failed to send to %s.', 'all-in-one-seo-pack' ), $email ) . '</div>'; 
  259. } else { 
  260. echo "<div class='sfwd_debug_error'>" . __( 'Error: please enter an e-mail address before submitting.', 'all-in-one-seo-pack' ) . '</div>'; 
  261. } while ( 0 ); // Control structure for use with break. 
  262. $nonce = wp_create_nonce( 'sfwd-debug-nonce' ); 
  263. $buf = "<ul class='sfwd_debug_settings'>\n{$page_text}\n</ul>\n<p>\n" . 
  264. '<input name="sfwd_debug_send_email" type="text" value="" placeholder="' . __( 'E-mail debug information', 'all-in-one-seo-pack' ) . '"><input name="sfwd_debug_nonce" type="hidden" value="' . 
  265. $nonce . '"><input name="sfwd_debug_submit" type="submit" value="' . __( 'Submit', 'all-in-one-seo-pack' ) . '" class="button-primary">'; 
  266.  
  267. if ( AIOSEOPPRO ) { 
  268. $buf .= '<p><input name="sfwd_update_check" type="submit" value="' . __( 'Check For Updates', 'all-in-one-seo-pack' ) . '" class="button-primary">'; 
  269.  
  270. return $buf;