Changeset 2996487
- Timestamp:
- 11/15/2023 03:13:00 PM (2 years ago)
- Location:
- a2-optimized-wp/tags/3.0.7
- Files:
-
- 6 edited
- 1 copied
-
. (copied) (copied from a2-optimized-wp/trunk)
-
a2-optimized.php (modified) (2 diffs)
-
app/templates/admin/page-settings/page-settings.php (modified) (4 diffs)
-
core/A2_Optimized_CacheEngine.php (modified) (7 diffs)
-
core/A2_Optimized_Optimizations.php (modified) (5 diffs)
-
core/A2_Optimized_SiteHealth.php (modified) (46 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
a2-optimized-wp/tags/3.0.7/a2-optimized.php
r2984569 r2996487 10 10 * Plugin Name: A2 Optimized WP 11 11 * Plugin URI: https://wordpress.org/plugins/a2-optimized/ 12 * Version: 3.0. 6.612 * Version: 3.0.7 13 13 * Author: A2 Hosting 14 14 * Author URI: https://www.a2hosting.com/ … … 25 25 26 26 define( 'A2OPT_VERSION', '3.0' ); 27 define( 'A2OPT_FULL_VERSION', '3.0. 6.6' );27 define( 'A2OPT_FULL_VERSION', '3.0.7' ); 28 28 define( 'A2OPT_MIN_PHP', '5.6' ); 29 29 define( 'A2OPT_MIN_WP', '5.1' ); -
a2-optimized-wp/tags/3.0.7/app/templates/admin/page-settings/page-settings.php
r2904009 r2996487 2 2 <script> 3 3 let page_data = <?php echo $data['data_json'] ?>; 4 page_data.login_url = '<?php echo esc_url(get_home_url()) . "/wp-login.php"?>';4 page_data.login_url = '<?php echo esc_url(get_home_url()) . '/wp-login.php' ?>'; 5 5 page_data.show_coaching = false; 6 6 page_data.showModal = false; … … 457 457 <span class="glyphicon glyphicon-ok-circle" :class="item.color_class" aria-hidden="true"></span> 458 458 </span> 459 <a :href="item.config_url" target="a2opt_config">Modify</a><br><span class="small">via wordpress</span> 459 <span v-if="item.config_url"> 460 <a :href="item.config_url" target="a2opt_config">Modify</a><br><span class="small">via wordpress</span> 461 </span> 460 462 </div> 461 463 <div v-else class="col-md-4 col-lg-3 text-right"> … … 875 877 </div> 876 878 <?php $reporting_active = get_option('a2_sitedata_allow'); 877 if(!$reporting_active){ 878 $data_nonce = wp_create_nonce('a2opt_datacollection_nonce'); 879 ?> 879 if (!$reporting_active) { 880 $data_nonce = wp_create_nonce('a2opt_datacollection_nonce'); ?> 880 881 <div class="row"> 881 882 <div class="notice notice-warning"> … … 885 886 </div> 886 887 </div> 887 <?php }; ?> 888 <?php 889 } ?> 888 890 <div class="row" id="a2-optimized-nav"> 889 891 <div class="col-md-12 col-lg-11 col-lg-offset-1"> -
a2-optimized-wp/tags/3.0.7/core/A2_Optimized_CacheEngine.php
r2813753 r2996487 35 35 * 36 36 */ 37 37 38 38 public static $request_headers; 39 39 … … 104 104 105 105 // check request URI 106 if ( str_replace( array( '.ico', '.txt', '.xml', '.xsl' ), '', $_SERVER['REQUEST_URI'] ) !== $_SERVER['REQUEST_URI'] ) {106 if ( str_replace( [ '.ico', '.txt', '.xml', '.xsl' ], '', $_SERVER['REQUEST_URI'] ) !== $_SERVER['REQUEST_URI'] ) { 107 107 return false; 108 108 } … … 149 149 150 150 private static function get_request_headers() { 151 $request_headers = ( function_exists( 'apache_request_headers' ) ) ? apache_request_headers() : array();152 153 $request_headers = array(151 $request_headers = ( function_exists( 'apache_request_headers' ) ) ? apache_request_headers() : []; 152 153 $request_headers = [ 154 154 'Accept' => ( isset( $request_headers['Accept'] ) ) ? $request_headers['Accept'] : ( ( isset( $_SERVER[ 'HTTP_ACCEPT' ] ) ) ? $_SERVER[ 'HTTP_ACCEPT' ] : '' ), 155 155 'Accept-Encoding' => ( isset( $request_headers['Accept-Encoding'] ) ) ? $request_headers['Accept-Encoding'] : ( ( isset( $_SERVER[ 'HTTP_ACCEPT_ENCODING' ] ) ) ? $_SERVER[ 'HTTP_ACCEPT_ENCODING' ] : '' ), … … 159 159 'X-Forwarded-Proto' => ( isset( $request_headers['X-Forwarded-Proto'] ) ) ? $request_headers['X-Forwarded-Proto'] : ( ( isset( $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] ) ) ? $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] : '' ), 160 160 'X-Forwarded-Scheme' => ( isset( $request_headers['X-Forwarded-Scheme'] ) ) ? $request_headers['X-Forwarded-Scheme'] : ( ( isset( $_SERVER[ 'HTTP_X_FORWARDED_SCHEME' ] ) ) ? $_SERVER[ 'HTTP_X_FORWARDED_SCHEME' ] : '' ), 161 );161 ]; 162 162 163 163 return $request_headers; … … 237 237 $post_id = get_queried_object_id(); 238 238 $excluded_post_ids = array_map( 'absint', (array) explode( ',', self::$settings['excluded_post_ids'] ) ); 239 239 240 240 if ( in_array( $post_id, $excluded_post_ids, true ) ) { 241 241 return true; … … 274 274 $cookies_regex = self::$settings['excluded_cookies']; 275 275 } else { 276 $cookies_regex = '/^(wp-postpass|wordpress_logged_in|comment_author)_/'; 276 if (is_plugin_active('woocommerce/woocommerce.php')) { 277 $cookies_regex = '/^(wp-postpass|wordpress_logged_in|comment_author|woocommerce_cart_hash|woocommerce_items_in_cart|woocommerce_recently_viewed)_/'; 278 } else { 279 $cookies_regex = '/^(wp-postpass|wordpress_logged_in|comment_author)_/'; 280 } 277 281 } 278 282 // bypass cache if an excluded cookie is found … … 361 365 public static function deliver_cache() { 362 366 $cache_file = A2_Optimized_Cache_Disk::get_cache(); 363 367 364 368 if ( A2_Optimized_Cache_Disk::cache_exists( $cache_file ) && ! A2_Optimized_Cache_Disk::cache_expired( $cache_file ) && ! self::bypass_cache() ) { 365 369 // set X-Cache-Handler response header -
a2-optimized-wp/tags/3.0.7/core/A2_Optimized_Optimizations.php
r2964157 r2996487 31 31 } 32 32 } 33 } 34 35 public function get_incompatible_plugins() { 36 return [ 37 'wp-optimize/wp-optimize.php', 38 'w3-total-cache/w3-total-cache.php', 39 'wp-fastest-cache/wpFastestCache.php', 40 'wp-super-cache/wp-cache.php', 41 'surge/surge.php', 42 'hummingbird-performance/wp-hummingbird.php', 43 'wp-rocket/wp-rocket.php', 44 'comet-cache/comet-cache.php', 45 'autoptimize/autoptimize.php', 46 'wp-smushit/wp-smush.php', 47 'imagify/imagify.php', 48 'shortpixel-image-optimiser/wp-shortpixel.php', 49 ]; 33 50 } 34 51 … … 834 851 'status' => $this->is_active('posts_per_rss', false), 835 852 ], 853 'post_revisions' => [ 854 'title' => 'Post Revisions', 855 'description' => 'The number of post revisions should be less than than 10 for most sites. This could slow down page loads.', 856 'status' => $this->is_active('post_revisions', false), 857 ], 836 858 'show_on_front' => [ 837 859 'title' => 'Recent Posts showing on home page', … … 857 879 'config_url' => admin_url() . 'plugins.php', 858 880 'status' => $this->is_active('plugins', false), 881 ], 882 'incompatible_plugins' => [ 883 'title' => 'Incompatible Plugins', 884 'description' => 'Some caching and optimization plugins will interfere with A2 Optimized or Litespeed cache. These plugins should be disabled.', 885 'config_url' => admin_url() . 'plugins.php', 886 'status' => $this->is_active('incompatible_plugins', false), 887 ], 888 'default_admin_user' => [ 889 'title' => 'Default "Admin" User', 890 'description' => 'Having a user with the login of "admin" could make your site more vulnerable to brute force attacks. This user should be replaced with less common username.', 891 'config_url' => admin_url() . 'users.php', 892 'status' => $this->is_active('default_admin_user', false), 893 ], 894 'default_db_prefix' => [ 895 'title' => 'Default Database Prefix', 896 'description' => 'Having a database prefix of "wp_" could make it easier for your site to be compromised.', 897 'status' => $this->is_active('default_db_prefix', false), 898 ], 899 'large_images' => [ 900 'title' => 'Large Images in the Media Library', 901 'description' => 'Images larger than 1mb may not be properly optimized and could cause performance issues for your site visitors.', 902 'config_url' => admin_url() . 'upload.php', 903 'status' => $this->is_active('large_images', false), 904 ], 905 'disable_trackbacks' => [ 906 'title' => 'Disable Trackbacks and Pingbacks', 907 'description' => 'Trackbacks and Pingbacks could contribute to slower page load times and increased spam content on your site.', 908 'config_url' => admin_url() . 'options-discussion.php', 909 'status' => $this->is_active('disable_trackbacks', false), 910 ], 911 'anyone_can_register' => [ 912 'title' => 'Anyone Can Register', 913 'description' => 'Allowing anyone to register to your site could lead to increased spam content.', 914 'config_url' => admin_url() . 'options-general.php', 915 'status' => $this->is_active('anyone_can_register', false), 916 ], 917 'remove_dummy_content' => [ 918 'title' => 'Remove default WordPress Content', 919 'description' => 'When setting up a new WordPress site, some default content is created. The "Hello World" post and "Sample Page" should be removed as they could be considered duplicate content.', 920 'config_url' => admin_url() . 'edit.php', 921 'status' => $this->is_active('remove_dummy_content', false), 922 ], 923 'privacy_policy' => [ 924 'title' => 'Site has a Privacy Policy', 925 'description' => 'When setting up a new WordPress site, a draft "Privacy Policy" page is created. This should be populated and published.', 926 'config_url' => admin_url() . 'edit.php?post_type=page', 927 'status' => $this->is_active('privacy_policy', false), 928 ], 929 'default_category' => [ 930 'title' => 'Default Post Category is "Uncategorized"', 931 'description' => 'When setting up a new WordPress site, the default category for posts is "Uncategorized". This category should be replaced with one better suited to your content.', 932 'config_url' => admin_url() . 'options-writing.php', 933 'status' => $this->is_active('default_category', false), 859 934 ], 860 935 'a2_hosting' => [ … … 1214 1289 1215 1290 break; 1291 case 'post_revisions': 1292 if (defined('WP_POST_REVISIONS') && WP_POST_REVISIONS == true) { 1293 // post revisions are active 1294 if (is_numeric(WP_POST_REVISIONS) && WP_POST_REVISIONS <= 10) { 1295 $result['current'] = 'Post revisions are enabled, but less than 10.'; 1296 $result['value'] = true; 1297 } else { 1298 $result['current'] = 'Post revisions are enabled with a limit higher than 10.'; 1299 $result['value'] = false; 1300 } 1301 } else { 1302 // No post revisions 1303 $result['current'] = 'Post revisions are disabled.'; 1304 $result['value'] = true; 1305 } 1306 1307 break; 1216 1308 case 'show_on_front': 1217 1309 $sof = get_option('show_on_front'); … … 1275 1367 $result['value'] = true; 1276 1368 } 1369 1370 break; 1371 case 'incompatible_plugins': 1372 $active_plugins = get_option('active_plugins'); 1373 $found_plugins = []; 1374 $plugin_list = null; 1375 $incompatible_plugins = $this->get_incompatible_plugins(); 1376 foreach ($active_plugins as $active_plugin) { 1377 if (in_array($active_plugin, $incompatible_plugins)) { 1378 $plugin_folder = explode('/', $active_plugin); 1379 $found_plugins[] = $plugin_folder[0]; 1380 } 1381 } 1382 if (count($found_plugins) > 0) { 1383 $result['value'] = false; 1384 $plugin_list = implode(', ', $found_plugins); 1385 } else { 1386 $result['value'] = true; 1387 } 1388 $result['current'] = count($found_plugins) . ' incompatible plugins.'; 1389 if ($plugin_list) { 1390 $result['current'] .= ' ' . $plugin_list; 1391 } 1392 1393 break; 1394 case 'default_admin_user': 1395 $users = get_users( [ 'role__in' => [ 'author', 'editor', 'administrator', 'shop_manager' ] ] ); 1396 $found_admin = false; 1397 foreach ($users as $user) { 1398 if (strtolower($user->user_login) == 'admin') { 1399 $found_admin = true; 1400 } 1401 } 1402 if ($found_admin) { 1403 $result['current'] = 'A privileged user with the login of "admin" was found.'; 1404 $result['value'] = false; 1405 } else { 1406 $result['current'] .= 'No user with the login of "admin" was found.'; 1407 $result['value'] = true; 1408 } 1409 1410 break; 1411 case 'default_db_prefix': 1412 global $wpdb; 1413 if ($wpdb->prefix == 'wp_') { 1414 $result['value'] = false; 1415 } else { 1416 $result['value'] = true; 1417 } 1418 $result['current'] = 'Your DB prefix is: ' . $wpdb->prefix . '.'; 1419 1420 break; 1421 case 'large_images': 1422 $large_files = 0; 1423 1424 $args = [ 1425 'post_type' => 'attachment', 1426 'numberposts' => -1, 1427 'post_mime_type' => 'image', 1428 'post_status' => null, 1429 'post_parent' => null, // any parent 1430 ]; 1431 $attachments = get_posts($args); 1432 if ($attachments) { 1433 foreach ($attachments as $post) { 1434 setup_postdata($post); 1435 $file = wp_get_original_image_path($post->ID); 1436 if (((filesize($file) / 1024) / 1024) > 1) { 1437 $large_files++; 1438 } 1439 } 1440 } 1441 1442 if ($large_files > 0) { 1443 $result['value'] = false; 1444 } else { 1445 $result['value'] = true; 1446 } 1447 $result['current'] = 'Found ' . $large_files . ' large images.'; 1448 1449 break; 1450 case 'disable_trackbacks': 1451 $ping_status = get_option('default_ping_status'); 1452 if ($ping_status && $ping_status == 'open') { 1453 $result['value'] = false; 1454 } else { 1455 $result['value'] = true; 1456 $ping_status = 'closed'; 1457 } 1458 $result['current'] = 'Pingback and Trackback status is currently ' . $ping_status . '.'; 1459 1460 break; 1461 case 'anyone_can_register': 1462 $register_status = get_option('users_can_register'); 1463 if ($register_status && $register_status == '1') { 1464 $result['value'] = false; 1465 $register_status = 'open'; 1466 } else { 1467 $result['value'] = true; 1468 $register_status = 'closed'; 1469 } 1470 $result['current'] = 'Registration on your site is currently ' . $register_status . '.'; 1471 1472 break; 1473 case 'remove_dummy_content': 1474 $found_default_content = []; 1475 1476 $hello_query = new WP_Query( [ 'name' => 'hello-world' ] ); 1477 if ( $hello_query->have_posts() ) { 1478 $found_default_content[] = 'Hello World!'; 1479 } 1480 $sample_query = new WP_Query( [ 'pagename' => 'sample-page' ] ); 1481 if ( $sample_query->have_posts() ) { 1482 $found_default_content[] = 'Sample Page'; 1483 } 1484 1485 if (count($found_default_content) > 0) { 1486 $result['value'] = false; 1487 $result['current'] = 'Found the following default content: ' . implode(', ', $found_default_content); 1488 } else { 1489 $result['value'] = true; 1490 $result['current'] = 'No default content found.'; 1491 } 1492 1493 break; 1494 case 'privacy_policy': 1495 $priv_query = new WP_Query( [ 'pagename' => 'privacy-policy' ] ); 1496 if ( $priv_query->have_posts() ) { 1497 $result['value'] = true; 1498 $result['current'] = 'Found a Privacy Policy page.'; 1499 } else { 1500 $result['value'] = false; 1501 $result['current'] = 'Privacy policy page may not be published'; 1502 } 1503 1504 break; 1505 case 'default_category': 1506 $default_category = get_option('default_category'); 1507 $term = get_term($default_category); 1508 if ($term->slug == 'uncategorized') { 1509 $result['value'] = false; 1510 } else { 1511 $result['value'] = true; 1512 } 1513 $result['current'] = 'Default post category is ' . $term->name . ' (' . $term->slug . ').'; 1277 1514 1278 1515 break; -
a2-optimized-wp/tags/3.0.7/core/A2_Optimized_SiteHealth.php
r2881444 r2996487 26 26 */ 27 27 protected function hooks() { 28 add_filter( 'debug_information', array( $this, 'add_debug_section' ) ); 29 add_filter( 'site_status_tests', array( $this, 'add_site_status_items' ) ); 30 31 } 32 28 add_filter( 'debug_information', [ $this, 'add_debug_section' ] ); 29 add_filter( 'site_status_tests', [ $this, 'add_site_status_items' ] ); 30 } 33 31 34 32 /** … … 39 37 * @return array Array with added A2 Optimized items. 40 38 */ 41 public function add_button_to_site_health_info_tab( $tab) {39 public function add_button_to_site_health_info_tab($tab) { 42 40 // Do nothing if this is not the "debug" tab. 43 41 if ( 'debug' !== $tab ) { 44 42 return; 45 } 46 ?> 43 } ?> 47 44 <div class='health-check-body health-check-debug-tab hide-if-no-js'> 48 45 <a href='admin.php?a2-page=site_health&page=A2_Optimized_Plugin_admin'><button class='button'>Save Report</button></a> … … 61 58 if (php_sapi_name() == 'litespeed') { 62 59 // Litespeed server 63 $tests['direct']['a2_optimized_turbocache'] = array(60 $tests['direct']['a2_optimized_turbocache'] = [ 64 61 'label' => 'TurboCache', 65 'test' => array( $this, 'a2opt_turbocache_test' ),66 );67 } 68 69 $tests['direct']['a2_optimized_revisions'] = array(62 'test' => [ $this, 'a2opt_turbocache_test' ], 63 ]; 64 } 65 66 $tests['direct']['a2_optimized_revisions'] = [ 70 67 'label' => 'Large amount of revisions', 71 'test' => array( $this, 'a2opt_revision_count_test' ),72 );73 74 $tests['direct']['a2_optimized_large_images'] = array(68 'test' => [ $this, 'a2opt_revision_count_test' ], 69 ]; 70 71 $tests['direct']['a2_optimized_large_images'] = [ 75 72 'label' => 'Large images in Media Library', 76 'test' => array( $this, 'a2opt_large_image_test' ),77 );78 79 $tests['direct']['a2_optimized_blocking_search'] = array(73 'test' => [ $this, 'a2opt_large_image_test' ], 74 ]; 75 76 $tests['direct']['a2_optimized_blocking_search'] = [ 80 77 'label' => 'Blocking search engines', 81 'test' => array( $this, 'a2opt_block_search_test' ),82 );83 84 $tests['direct']['a2_optimized_caching'] = array(78 'test' => [ $this, 'a2opt_block_search_test' ], 79 ]; 80 81 $tests['direct']['a2_optimized_caching'] = [ 85 82 'label' => 'Caching enabled', 86 'test' => array( $this, 'a2opt_cache_test' ),87 );88 89 $tests['direct']['a2_optimized_phpopcache'] = array(83 'test' => [ $this, 'a2opt_cache_test' ], 84 ]; 85 86 $tests['direct']['a2_optimized_phpopcache'] = [ 90 87 'label' => 'PHP OP Caching enabled', 91 'test' => array( $this, 'a2opt_phpopcache_test' ),92 );93 94 $tests['direct']['a2_optimized_other_cache'] = array(88 'test' => [ $this, 'a2opt_phpopcache_test' ], 89 ]; 90 91 $tests['direct']['a2_optimized_other_cache'] = [ 95 92 'label' => 'Duplicate Caching plugins enabled', 96 'test' => array( $this, 'a2opt_other_cache_test' ),97 );98 99 $tests['direct']['a2_optimized_php_memory'] = array(93 'test' => [ $this, 'a2opt_other_cache_test' ], 94 ]; 95 96 $tests['direct']['a2_optimized_php_memory'] = [ 100 97 'label' => 'PHP has good memory limits', 101 'test' => array( $this, 'a2opt_php_memory_test' ), 102 ); 103 104 98 'test' => [ $this, 'a2opt_php_memory_test' ], 99 ]; 100 105 101 if (is_plugin_active('woocommerce/woocommerce.php')) { 106 $tests['direct']['a2_optimized_cart_fragments'] = array(102 $tests['direct']['a2_optimized_cart_fragments'] = [ 107 103 'label' => 'Dequeue WooCommerce Cart Fragments AJAX calls', 108 'test' => array( $this, 'a2opt_cart_fragments_test' ),109 );110 } 111 112 $tests['direct']['a2_optimized_gzip_compression'] = array(104 'test' => [ $this, 'a2opt_cart_fragments_test' ], 105 ]; 106 } 107 108 $tests['direct']['a2_optimized_gzip_compression'] = [ 113 109 'label' => 'Gzip Compression Enabled', 114 'test' => array( $this, 'a2opt_gzip_test' ),115 );116 117 $tests['direct']['a2_optimized_block_xmlrpc'] = array(110 'test' => [ $this, 'a2opt_gzip_test' ], 111 ]; 112 113 $tests['direct']['a2_optimized_block_xmlrpc'] = [ 118 114 'label' => 'Block Unauthorized XML-RPC Requests', 119 'test' => array( $this, 'a2opt_xml_rpc_test' ),120 );121 122 $tests['direct']['a2_optimized_disable_fileedit'] = array(115 'test' => [ $this, 'a2opt_xml_rpc_test' ], 116 ]; 117 118 $tests['direct']['a2_optimized_disable_fileedit'] = [ 123 119 'label' => 'Lock Editing of Plugins and Themes from the WP Admin', 124 'test' => array( $this, 'a2opt_file_edit_test' ),125 );126 120 'test' => [ $this, 'a2opt_file_edit_test' ], 121 ]; 122 127 123 return $tests; 128 124 } … … 134 130 */ 135 131 public function a2opt_turbocache_test() { 136 $result = array(132 $result = [ 137 133 'label' => __( 'TurboCache is enabled' ), 138 134 'status' => 'good', // Default "passing" section 139 'badge' => array(140 'label' => __( 'Performance' ), 141 'color' => 'orange', 142 ),135 'badge' => [ 136 'label' => __( 'Performance' ), 137 'color' => 'orange', 138 ], 143 139 'description' => sprintf( 144 140 '<p>%s</p>', … … 147 143 'actions' => '', 148 144 'test' => 'caching_plugin', 149 );150 145 ]; 146 151 147 if (!is_plugin_active('litespeed-cache/litespeed-cache.php') || !get_option('litespeed.conf.cache')) { 152 148 $result['status'] = 'critical'; // "Critical" section … … 165 161 return $result; 166 162 } 167 163 168 164 /** 169 165 * Check if Revision count is too large … … 172 168 */ 173 169 public function a2opt_revision_count_test() { 174 $result = array(170 $result = [ 175 171 'label' => __( 'Reasonable number of post revisions' ), 176 172 'status' => 'good', // Default "passing" section 177 'badge' => array(178 'label' => __( 'Performance' ), 179 'color' => 'orange', 180 ),173 'badge' => [ 174 'label' => __( 'Performance' ), 175 'color' => 'orange', 176 ], 181 177 'description' => sprintf( 182 178 '<p>%s</p>', … … 185 181 'actions' => '', 186 182 'test' => 'revision_count', 187 );188 189 $args = array(183 ]; 184 185 $args = [ 190 186 'numberposts' => -1, 191 187 'post_type' => 'revision' 192 );193 188 ]; 189 194 190 $post_revisions = get_posts( $args ); 195 191 … … 205 201 return $result; 206 202 } 207 203 208 204 /** 209 205 * Check if large images are in the media library … … 212 208 */ 213 209 public function a2opt_large_image_test() { 214 $result = array(210 $result = [ 215 211 'label' => __( 'Media library images are a reasonable size' ), 216 212 'status' => 'good', // Default "passing" section 217 'badge' => array(218 'label' => __( 'Performance' ), 219 'color' => 'orange', 220 ),213 'badge' => [ 214 'label' => __( 'Performance' ), 215 'color' => 'orange', 216 ], 221 217 'description' => sprintf( 222 218 '<p>%s</p>', … … 225 221 'actions' => '', 226 222 'test' => 'large_images', 227 );223 ]; 228 224 229 225 $large_image_count = 0; 230 226 231 $query_images_args = array(227 $query_images_args = [ 232 228 'post_type' => 'attachment', 233 229 'post_mime_type' => 'image', 234 230 'post_status' => 'inherit', 235 231 'posts_per_page' => -1, 236 );232 ]; 237 233 238 234 $query_images = new WP_Query( $query_images_args ); … … 258 254 return $result; 259 255 } 260 256 261 257 /** 262 258 * Check if discourage search engines is enabled … … 265 261 */ 266 262 public function a2opt_block_search_test() { 267 $result = array(263 $result = [ 268 264 'label' => __( 'Search engines are allowed' ), 269 265 'status' => 'good', // Default "passing" section 270 'badge' => array(271 'label' => __( 'Performance' ), 272 'color' => 'orange', 273 ),266 'badge' => [ 267 'label' => __( 'Performance' ), 268 'color' => 'orange', 269 ], 274 270 'description' => sprintf( 275 271 '<p>%s</p>', … … 278 274 'actions' => '', 279 275 'test' => 'blocking_search', 280 );276 ]; 281 277 282 278 if (get_option('blog_public') == 0) { … … 291 287 return $result; 292 288 } 293 289 294 290 /** 295 291 * Check if caching is enabled … … 298 294 */ 299 295 public function a2opt_cache_test() { 300 $result = array(296 $result = [ 301 297 'label' => __( 'Site Caching is enabled' ), 302 298 'status' => 'good', // Default "passing" section 303 'badge' => array(304 'label' => __( 'Performance' ), 305 'color' => 'orange', 306 ),299 'badge' => [ 300 'label' => __( 'Performance' ), 301 'color' => 'orange', 302 ], 307 303 'description' => sprintf( 308 304 '<p>%s</p>', … … 311 307 'actions' => '', 312 308 'test' => 'caching_enabled', 313 );309 ]; 314 310 315 311 if (!is_plugin_active('litespeed-cache/litespeed-cache.php') && get_option('a2_cache_enabled') != 1) { … … 329 325 return $result; 330 326 } 331 327 332 328 /** 333 329 * Check if PHP OpCache is enabled … … 336 332 */ 337 333 public function a2opt_phpopcache_test() { 338 $result = array(334 $result = [ 339 335 'label' => __( 'PHP OpCaching is enabled' ), 340 336 'status' => 'good', // Default "passing" section 341 'badge' => array(342 'label' => __( 'Performance' ), 343 'color' => 'orange', 344 ),337 'badge' => [ 338 'label' => __( 'Performance' ), 339 'color' => 'orange', 340 ], 345 341 'description' => sprintf( 346 342 '<p>%s</p>', … … 349 345 'actions' => '', 350 346 'test' => 'opcaching_enabled', 351 );352 353 if (function_exists('opcache_get_status')){347 ]; 348 349 if (function_exists('opcache_get_status')) { 354 350 $opcache_status = opcache_get_status(); 355 351 } else { 356 352 $opcache_status = false; 357 } ;353 } 358 354 359 355 if (!is_array($opcache_status) || !$opcache_status['opcache_enabled']) { … … 368 364 return $result; 369 365 } 370 366 371 367 /** 372 368 * Check if other caching plugins are enabled … … 375 371 */ 376 372 public function a2opt_other_cache_test() { 377 $result = array(373 $result = [ 378 374 'label' => __( 'No conflicting cache plugins detected' ), 379 375 'status' => 'good', // Default "passing" section 380 'badge' => array(381 'label' => __( 'Performance' ), 382 'color' => 'orange', 383 ),376 'badge' => [ 377 'label' => __( 'Performance' ), 378 'color' => 'orange', 379 ], 384 380 'description' => sprintf( 385 381 '<p>%s</p>', … … 388 384 'actions' => '', 389 385 'test' => 'caching_enabled', 390 );386 ]; 391 387 392 388 $active_plugins = get_option('active_plugins'); 393 394 $incompatible_plugins = array( 395 'wp-super-cache', 396 'wp-fastest-cache', 397 'wp-file-cache', 398 'w3-total-cache', 399 'sg-cachepress', 400 'cache-enabler', 401 'comet-cache', 402 'wp-rocket', 403 'surge' 404 ); 405 389 390 $a2_optimizations = new A2_Optimized_Optimizations; 391 392 $incompatible_plugins = $a2_optimizations->get_incompatible_plugins(); 393 406 394 $found_plugin = false; 407 395 408 396 foreach ($active_plugins as $active_plugin) { 409 397 $plugin_folder = explode('/', $active_plugin); … … 429 417 return $result; 430 418 } 431 419 432 420 /** 433 421 * Check PHP Memory limits … … 436 424 */ 437 425 public function a2opt_php_memory_test() { 438 $result = array(426 $result = [ 439 427 'label' => __( 'PHP has good memory limits' ), 440 428 'status' => 'good', // Default "passing" section 441 'badge' => array(442 'label' => __( 'Performance' ), 443 'color' => 'orange', 444 ),429 'badge' => [ 430 'label' => __( 'Performance' ), 431 'color' => 'orange', 432 ], 445 433 'description' => sprintf( 446 434 '<p>%s</p>', … … 449 437 'actions' => '', 450 438 'test' => 'php_memory', 451 );439 ]; 452 440 453 441 $memory_limit = $this->return_bytes(ini_get('memory_limit')); … … 463 451 return $result; 464 452 } 465 453 466 454 /** 467 455 * Check number of unused plugins … … 470 458 */ 471 459 public function a2opt_plugin_count_test() { 472 $result = array(460 $result = [ 473 461 'label' => __( 'Large number of unused plugins' ), 474 462 'status' => 'good', // Default "passing" section 475 'badge' => array(476 'label' => __( 'Performance' ), 477 'color' => 'orange', 478 ),463 'badge' => [ 464 'label' => __( 'Performance' ), 465 'color' => 'orange', 466 ], 479 467 'description' => sprintf( 480 468 '<p>%s</p>', … … 483 471 'actions' => '', 484 472 'test' => 'plugin_count', 485 );473 ]; 486 474 487 475 $plugins = get_plugins(); … … 501 489 return $result; 502 490 } 503 491 504 492 /** 505 493 * Check number of unused themes … … 508 496 */ 509 497 public function a2opt_theme_count_test() { 510 $result = array(498 $result = [ 511 499 'label' => __( 'Large number of unused themes' ), 512 500 'status' => 'good', // Default "passing" section 513 'badge' => array(514 'label' => __( 'Performance' ), 515 'color' => 'orange', 516 ),501 'badge' => [ 502 'label' => __( 'Performance' ), 503 'color' => 'orange', 504 ], 517 505 'description' => sprintf( 518 506 '<p>%s</p>', … … 521 509 'actions' => '', 522 510 'test' => 'theme_count', 523 );511 ]; 524 512 525 513 $themes = wp_get_themes(); … … 540 528 return $result; 541 529 } 542 530 543 531 /** 544 532 * Check if Cart Fragment AJAX calls are dequeued … … 547 535 */ 548 536 public function a2opt_cart_fragments_test() { 549 $result = array(537 $result = [ 550 538 'label' => __( 'Dequeue WooCommerce Cart Fragments AJAX calls' ), 551 539 'status' => 'good', // Default "passing" section 552 'badge' => array(553 'label' => __( 'Performance' ), 554 'color' => 'orange', 555 ),540 'badge' => [ 541 'label' => __( 'Performance' ), 542 'color' => 'orange', 543 ], 556 544 'description' => sprintf( 557 545 '<p>%s</p>', … … 560 548 'actions' => '', 561 549 'test' => 'cart_fragments', 562 );550 ]; 563 551 564 552 if (!get_option('a2_wc_cart_fragments')) { … … 568 556 return $result; 569 557 } 570 558 571 559 /** 572 560 * Check if GZIP compression is enabled … … 575 563 */ 576 564 public function a2opt_gzip_test() { 577 $result = array(565 $result = [ 578 566 'label' => __( 'You should enable GZIP compression' ), 579 567 'status' => 'recommended', // Default "failing" section 580 'badge' => array(581 'label' => __( 'Performance' ), 582 'color' => 'orange', 583 ),568 'badge' => [ 569 'label' => __( 'Performance' ), 570 'color' => 'orange', 571 ], 584 572 'description' => sprintf( 585 573 '<p>%s</p>', … … 588 576 'actions' => '', 589 577 'test' => 'gzip_compression', 590 );591 592 if (is_plugin_active('litespeed-cache/litespeed-cache.php')){578 ]; 579 580 if (is_plugin_active('litespeed-cache/litespeed-cache.php')) { 593 581 $result['status'] = 'good'; 594 } 595 else if(get_option('a2_cache_enabled') == 1 && A2_Optimized_Cache_Engine::$settings['compress_cache']) { 582 } elseif (get_option('a2_cache_enabled') == 1 && A2_Optimized_Cache_Engine::$settings['compress_cache']) { 596 583 $result['status'] = 'good'; 597 584 } … … 599 586 return $result; 600 587 } 601 588 602 589 /** 603 590 * Check if XML-RPC requests are blocked … … 606 593 */ 607 594 public function a2opt_xml_rpc_test() { 608 $result = array(595 $result = [ 609 596 'label' => __( 'Block Unauthorized XML-RPC Requests' ), 610 597 'status' => 'good', // Default "passing" section 611 'badge' => array(612 'label' => __( 'Performance' ), 613 'color' => 'orange', 614 ),598 'badge' => [ 599 'label' => __( 'Performance' ), 600 'color' => 'orange', 601 ], 615 602 'description' => sprintf( 616 603 '<p>%s</p>', … … 619 606 'actions' => '', 620 607 'test' => 'block_xmlrpc', 621 );608 ]; 622 609 623 610 if (!get_option('a2_block_xmlrpc')) { … … 634 621 */ 635 622 public function a2opt_file_edit_test() { 636 $result = array(623 $result = [ 637 624 'label' => __( 'Lock Editing of Plugins and Themes from the WP Admin' ), 638 625 'status' => 'good', // Default "passing" section 639 'badge' => array(640 'label' => __( 'Performance' ), 641 'color' => 'orange', 642 ),626 'badge' => [ 627 'label' => __( 'Performance' ), 628 'color' => 'orange', 629 ], 643 630 'description' => sprintf( 644 631 '<p>%s</p>', … … 647 634 'actions' => '', 648 635 'test' => 'file_edit', 649 );636 ]; 650 637 651 638 if (!get_option('a2_optimized_lockdown')) { … … 655 642 return $result; 656 643 } 657 644 658 645 /** 659 646 * Add A2 Optimized section to Info tab. … … 664 651 */ 665 652 public function add_debug_section($debug_info) { 666 $a2_optimized = array(653 $a2_optimized = [ 667 654 'label' => 'A2Optimized', 668 'fields' => array(669 'version' => array(655 'fields' => [ 656 'version' => [ 670 657 'label' => 'Version', 671 658 'value' => A2OPT_FULL_VERSION, 672 ),673 ),674 );675 659 ], 660 ], 661 ]; 662 676 663 /* MySQL Version */ 677 664 global $wpdb; 678 665 $mysqlVersion = $wpdb->db_version(); 679 666 680 $a2_optimized['fields']['mysql_version'] = array(667 $a2_optimized['fields']['mysql_version'] = [ 681 668 'label' => 'MySQL Version', 682 669 'value' => $mysqlVersion 683 );670 ]; 684 671 685 672 /* PHP Version */ 686 $a2_optimized['fields']['php_version'] = array(673 $a2_optimized['fields']['php_version'] = [ 687 674 'label' => 'PHP Version', 688 675 'value' => phpversion() 689 );690 676 ]; 677 691 678 /* CPU Info */ 692 if (function_exists('exec')){679 if (function_exists('exec')) { 693 680 $cpu_info = exec('cat /proc/cpuinfo | grep "model name\\|processor"'); 694 681 $cpu_info = str_replace('model name', '', $cpu_info); 695 682 $cpu_info = str_replace('processor', '', $cpu_info); 696 683 $cpu_info = str_replace(':', '', $cpu_info); 697 $a2_optimized['fields']['cpu_info'] = array(684 $a2_optimized['fields']['cpu_info'] = [ 698 685 'label' => 'CPU Info', 699 686 'value' => $cpu_info 700 );701 } ;702 687 ]; 688 } 689 703 690 /* Webserver info */ 704 $a2_optimized['fields']['http_server'] = array(691 $a2_optimized['fields']['http_server'] = [ 705 692 'label' => 'Web Server', 706 693 'value' => php_sapi_name() 707 );708 694 ]; 695 709 696 /* PHP Memory Limit */ 710 $a2_optimized['fields']['php_memory'] = array(697 $a2_optimized['fields']['php_memory'] = [ 711 698 'label' => 'PHP Memory Limit', 712 699 'value' => ini_get('memory_limit') 713 );714 700 ]; 701 715 702 /* Frontend Benchmarks */ 716 $frontend_benchmarks = get_option('a2opt-benchmarks-frontend'); 717 if (empty($frontend_benchmarks) || !is_array($frontend_benchmarks)){718 $a2_optimized['fields']['benchmark_frontend_overall'] = array(703 $frontend_benchmarks = get_option('a2opt-benchmarks-frontend'); 704 if (empty($frontend_benchmarks) || !is_array($frontend_benchmarks)) { 705 $a2_optimized['fields']['benchmark_frontend_overall'] = [ 719 706 'label' => 'Frontend Benchmark', 720 707 'value' => 'Test not run yet' 721 );708 ]; 722 709 } else { 723 710 $frontend_benchmarks_last = array_pop($frontend_benchmarks); 724 711 725 $a2_optimized['fields']['benchmark_frontend_overall'] = array(712 $a2_optimized['fields']['benchmark_frontend_overall'] = [ 726 713 'label' => 'Frontend Benchmark Overall Score', 727 714 'value' => $frontend_benchmarks_last['scores']['overall_score'] 728 );729 $a2_optimized['fields']['benchmark_frontend_fcp'] = array(715 ]; 716 $a2_optimized['fields']['benchmark_frontend_fcp'] = [ 730 717 'label' => 'Frontend Benchmark FCP', 731 718 'value' => $frontend_benchmarks_last['scores']['fcp'] 732 );733 $a2_optimized['fields']['benchmark_frontend_ttfb'] = array(719 ]; 720 $a2_optimized['fields']['benchmark_frontend_ttfb'] = [ 734 721 'label' => 'Frontend Benchmark TTFB', 735 722 'value' => $frontend_benchmarks_last['scores']['ttfb'] 736 );737 $a2_optimized['fields']['benchmark_frontend_lcp'] = array(723 ]; 724 $a2_optimized['fields']['benchmark_frontend_lcp'] = [ 738 725 'label' => 'Frontend Benchmark LCP', 739 726 'value' => $frontend_benchmarks_last['scores']['lcp'] 740 );741 $a2_optimized['fields']['benchmark_frontend_fid'] = array(727 ]; 728 $a2_optimized['fields']['benchmark_frontend_fid'] = [ 742 729 'label' => 'Frontend Benchmark FID', 743 730 'value' => $frontend_benchmarks_last['scores']['fid'] 744 );745 $a2_optimized['fields']['benchmark_frontend_cls'] = array(731 ]; 732 $a2_optimized['fields']['benchmark_frontend_cls'] = [ 746 733 'label' => 'Frontend Benchmark CLS', 747 734 'value' => $frontend_benchmarks_last['scores']['cls'] 748 );749 } 750 735 ]; 736 } 737 751 738 /* Backend Benchmarks */ 752 739 $backend_benchmarks = get_option('a2opt-benchmarks-hosting'); 753 if (empty($backend_benchmarks) || !is_array($backend_benchmarks)){754 $a2_optimized['fields']['benchmark_hosting_overall'] = array(740 if (empty($backend_benchmarks) || !is_array($backend_benchmarks)) { 741 $a2_optimized['fields']['benchmark_hosting_overall'] = [ 755 742 'label' => 'Hosting Benchmark', 756 743 'value' => 'Test not run yet' 757 );744 ]; 758 745 } else { 759 746 $backend_benchmarks_last = array_pop($backend_benchmarks); 760 $a2_optimized['fields']['benchmark_hosting_overall'] = array(747 $a2_optimized['fields']['benchmark_hosting_overall'] = [ 761 748 'label' => 'Hosting Benchmark Overall Score', 762 749 'value' => round($backend_benchmarks_last['wordpress_db']['queries_per_second']) 763 );764 $a2_optimized['fields']['benchmark_hosting_php'] = array(750 ]; 751 $a2_optimized['fields']['benchmark_hosting_php'] = [ 765 752 'label' => 'Hosting Benchmark PHP Score', 766 753 'value' => $backend_benchmarks_last['php']['total'] 767 );768 $a2_optimized['fields']['benchmark_hosting_mysql'] = array(754 ]; 755 $a2_optimized['fields']['benchmark_hosting_mysql'] = [ 769 756 'label' => 'Hosting Benchmark MySQL Score', 770 757 'value' => $backend_benchmarks_last['mysql']['benchmark']['mysql_total'] 771 );772 $a2_optimized['fields']['benchmark_hosting_filesystem'] = array(758 ]; 759 $a2_optimized['fields']['benchmark_hosting_filesystem'] = [ 773 760 'label' => 'Hosting Benchmark Filesystem Score', 774 761 'value' => $backend_benchmarks_last['filesystem'] 775 );762 ]; 776 763 } 777 764 … … 790 777 private function return_bytes($val) { 791 778 $val = trim($val); 792 $last = strtolower($val[strlen($val) -1]);779 $last = strtolower($val[strlen($val) - 1]); 793 780 $val = substr($val, 0, -1); 794 switch ($last) {781 switch ($last) { 795 782 case 'g': 796 783 $val *= 1024; 784 // no break 797 785 case 'm': 798 786 $val *= 1024; 787 // no break 799 788 case 'k': 800 789 $val *= 1024; 801 790 } 791 802 792 return $val; 803 793 } -
a2-optimized-wp/tags/3.0.7/readme.txt
r2984569 r2996487 3 3 Tags: a2 hosting, cache, caching, speed, fast, optimize, site performance, image optimization, image compression, site security, seo, gzip compression, minify code, code minification 4 4 Requires at least: 5.1 5 Tested up to: 6.4 6 Stable tag: 3.0. 6.65 Tested up to: 6.4.1 6 Stable tag: 3.0.7 7 7 Requires PHP: 5.6 8 8 License: GPLv3 … … 153 153 == Changelog == 154 154 155 = 3.0.7 = 156 * Revised list of Best Practices 157 * Built-in Disk Caching will now auto-detect and apply optimizations for WooCommerce 158 155 159 = 3.0.6.6 = 156 160 * Tested with WordPress 6.4
Note: See TracChangeset
for help on using the changeset viewer.