Plugin Directory

Changeset 2996487


Ignore:
Timestamp:
11/15/2023 03:13:00 PM (2 years ago)
Author:
a2hosting
Message:

Tagging version 3.0.7

Location:
a2-optimized-wp/tags/3.0.7
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • a2-optimized-wp/tags/3.0.7/a2-optimized.php

    r2984569 r2996487  
    1010 * Plugin Name: A2 Optimized WP
    1111 * Plugin URI: https://wordpress.org/plugins/a2-optimized/
    12  * Version: 3.0.6.6
     12 * Version: 3.0.7
    1313 * Author: A2 Hosting
    1414 * Author URI: https://www.a2hosting.com/
     
    2525
    2626define( 'A2OPT_VERSION', '3.0' );
    27 define( 'A2OPT_FULL_VERSION', '3.0.6.6' );
     27define( 'A2OPT_FULL_VERSION', '3.0.7' );
    2828define( 'A2OPT_MIN_PHP', '5.6' );
    2929define( 'A2OPT_MIN_WP', '5.1' );
  • a2-optimized-wp/tags/3.0.7/app/templates/admin/page-settings/page-settings.php

    r2904009 r2996487  
    22<script>
    33    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' ?>';
    55    page_data.show_coaching = false;
    66    page_data.showModal = false;
     
    457457                                                        <span class="glyphicon glyphicon-ok-circle"  :class="item.color_class" aria-hidden="true"></span>
    458458                                                    </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>
    460462                                                </div>
    461463                                                <div v-else class="col-md-4 col-lg-3 text-right">
     
    875877        </div>
    876878        <?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'); ?>
    880881        <div class="row">
    881882            <div class="notice notice-warning">
     
    885886            </div>
    886887        </div>
    887         <?php }; ?>
     888        <?php
     889        } ?>
    888890        <div class="row" id="a2-optimized-nav">
    889891            <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  
    3535     *
    3636     */
    37        
     37
    3838    public static $request_headers;
    3939
     
    104104
    105105        // 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'] ) {
    107107            return false;
    108108        }
     
    149149
    150150    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 = [
    154154            'Accept' => ( isset( $request_headers['Accept'] ) ) ? $request_headers['Accept'] : ( ( isset( $_SERVER[ 'HTTP_ACCEPT' ] ) ) ? $_SERVER[ 'HTTP_ACCEPT' ] : '' ),
    155155            'Accept-Encoding' => ( isset( $request_headers['Accept-Encoding'] ) ) ? $request_headers['Accept-Encoding'] : ( ( isset( $_SERVER[ 'HTTP_ACCEPT_ENCODING' ] ) ) ? $_SERVER[ 'HTTP_ACCEPT_ENCODING' ] : '' ),
     
    159159            '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' ] : '' ),
    160160            '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        ];
    162162
    163163        return $request_headers;
     
    237237            $post_id = get_queried_object_id();
    238238            $excluded_post_ids = array_map( 'absint', (array) explode( ',', self::$settings['excluded_post_ids'] ) );
    239        
     239
    240240            if ( in_array( $post_id, $excluded_post_ids, true ) ) {
    241241                return true;
     
    274274                $cookies_regex = self::$settings['excluded_cookies'];
    275275            } 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                }
    277281            }
    278282            // bypass cache if an excluded cookie is found
     
    361365    public static function deliver_cache() {
    362366        $cache_file = A2_Optimized_Cache_Disk::get_cache();
    363        
     367
    364368        if ( A2_Optimized_Cache_Disk::cache_exists( $cache_file ) && ! A2_Optimized_Cache_Disk::cache_expired( $cache_file ) && ! self::bypass_cache()  ) {
    365369            // set X-Cache-Handler response header
  • a2-optimized-wp/tags/3.0.7/core/A2_Optimized_Optimizations.php

    r2964157 r2996487  
    3131            }
    3232        }
     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        ];
    3350    }
    3451
     
    834851                'status' => $this->is_active('posts_per_rss', false),
    835852            ],
     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            ],
    836858            'show_on_front' => [
    837859                'title' => 'Recent Posts showing on home page',
     
    857879                'config_url' => admin_url() . 'plugins.php',
    858880                '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),
    859934            ],
    860935            'a2_hosting' => [
     
    12141289
    12151290                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;
    12161308            case 'show_on_front':
    12171309                $sof = get_option('show_on_front');
     
    12751367                    $result['value'] = true;
    12761368                }
     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 . ').';
    12771514
    12781515                break;
  • a2-optimized-wp/tags/3.0.7/core/A2_Optimized_SiteHealth.php

    r2881444 r2996487  
    2626     */
    2727    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    }
    3331
    3432    /**
     
    3937     * @return array Array with added A2 Optimized items.
    4038     */
    41     public function add_button_to_site_health_info_tab( $tab ) {
     39    public function add_button_to_site_health_info_tab($tab) {
    4240        // Do nothing if this is not the "debug" tab.
    4341        if ( 'debug' !== $tab ) {
    4442            return;
    45         }
    46         ?>
     43        } ?>
    4744        <div class='health-check-body health-check-debug-tab hide-if-no-js'>
    4845            <a href='admin.php?a2-page=site_health&page=A2_Optimized_Plugin_admin'><button class='button'>Save Report</button></a>
     
    6158        if (php_sapi_name() == 'litespeed') {
    6259            // Litespeed server
    63             $tests['direct']['a2_optimized_turbocache'] = array(
     60            $tests['direct']['a2_optimized_turbocache'] = [
    6461                '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'] = [
    7067            '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'] = [
    7572            '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'] = [
    8077            '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'] = [
    8582            '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'] = [
    9087            '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'] = [
    9592            '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'] = [
    10097            '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
    105101        if (is_plugin_active('woocommerce/woocommerce.php')) {
    106             $tests['direct']['a2_optimized_cart_fragments'] = array(
     102            $tests['direct']['a2_optimized_cart_fragments'] = [
    107103                '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'] = [
    113109            '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'] = [
    118114            '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'] = [
    123119            '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
    127123        return $tests;
    128124    }
     
    134130     */
    135131    public function a2opt_turbocache_test() {
    136         $result = array(
     132        $result = [
    137133            'label' => __( 'TurboCache is enabled' ),
    138134            'status' => 'good', // Default "passing" section
    139             'badge' => array(
    140                 'label' => __( 'Performance' ),
    141                 'color' => 'orange',
    142             ),
     135            'badge' => [
     136                'label' => __( 'Performance' ),
     137                'color' => 'orange',
     138            ],
    143139            'description' => sprintf(
    144140                '<p>%s</p>',
     
    147143            'actions' => '',
    148144            'test' => 'caching_plugin',
    149         );
    150  
     145        ];
     146
    151147        if (!is_plugin_active('litespeed-cache/litespeed-cache.php') || !get_option('litespeed.conf.cache')) {
    152148            $result['status'] = 'critical'; // "Critical" section
     
    165161        return $result;
    166162    }
    167    
     163
    168164    /**
    169165     * Check if Revision count is too large
     
    172168     */
    173169    public function a2opt_revision_count_test() {
    174         $result = array(
     170        $result = [
    175171            'label' => __( 'Reasonable number of post revisions' ),
    176172            'status' => 'good', // Default "passing" section
    177             'badge' => array(
    178                 'label' => __( 'Performance' ),
    179                 'color' => 'orange',
    180             ),
     173            'badge' => [
     174                'label' => __( 'Performance' ),
     175                'color' => 'orange',
     176            ],
    181177            'description' => sprintf(
    182178                '<p>%s</p>',
     
    185181            'actions' => '',
    186182            'test' => 'revision_count',
    187         );
    188  
    189         $args = array(
     183        ];
     184
     185        $args = [
    190186            'numberposts' => -1,
    191187            'post_type' => 'revision'
    192         );
    193  
     188        ];
     189
    194190        $post_revisions = get_posts( $args );
    195191
     
    205201        return $result;
    206202    }
    207    
     203
    208204    /**
    209205     * Check if large images are in the media library
     
    212208     */
    213209    public function a2opt_large_image_test() {
    214         $result = array(
     210        $result = [
    215211            'label' => __( 'Media library images are a reasonable size' ),
    216212            'status' => 'good', // Default "passing" section
    217             'badge' => array(
    218                 'label' => __( 'Performance' ),
    219                 'color' => 'orange',
    220             ),
     213            'badge' => [
     214                'label' => __( 'Performance' ),
     215                'color' => 'orange',
     216            ],
    221217            'description' => sprintf(
    222218                '<p>%s</p>',
     
    225221            'actions' => '',
    226222            'test' => 'large_images',
    227         );
     223        ];
    228224
    229225        $large_image_count = 0;
    230226
    231         $query_images_args = array(
     227        $query_images_args = [
    232228            'post_type' => 'attachment',
    233229            'post_mime_type' => 'image',
    234230            'post_status' => 'inherit',
    235231            'posts_per_page' => -1,
    236         );
     232        ];
    237233
    238234        $query_images = new WP_Query( $query_images_args );
     
    258254        return $result;
    259255    }
    260    
     256
    261257    /**
    262258     * Check if discourage search engines is enabled
     
    265261     */
    266262    public function a2opt_block_search_test() {
    267         $result = array(
     263        $result = [
    268264            'label' => __( 'Search engines are allowed' ),
    269265            'status' => 'good', // Default "passing" section
    270             'badge' => array(
    271                 'label' => __( 'Performance' ),
    272                 'color' => 'orange',
    273             ),
     266            'badge' => [
     267                'label' => __( 'Performance' ),
     268                'color' => 'orange',
     269            ],
    274270            'description' => sprintf(
    275271                '<p>%s</p>',
     
    278274            'actions' => '',
    279275            'test' => 'blocking_search',
    280         );
     276        ];
    281277
    282278        if (get_option('blog_public') == 0) {
     
    291287        return $result;
    292288    }
    293    
     289
    294290    /**
    295291     * Check if caching is enabled
     
    298294     */
    299295    public function a2opt_cache_test() {
    300         $result = array(
     296        $result = [
    301297            'label' => __( 'Site Caching is enabled' ),
    302298            'status' => 'good', // Default "passing" section
    303             'badge' => array(
    304                 'label' => __( 'Performance' ),
    305                 'color' => 'orange',
    306             ),
     299            'badge' => [
     300                'label' => __( 'Performance' ),
     301                'color' => 'orange',
     302            ],
    307303            'description' => sprintf(
    308304                '<p>%s</p>',
     
    311307            'actions' => '',
    312308            'test' => 'caching_enabled',
    313         );
     309        ];
    314310
    315311        if (!is_plugin_active('litespeed-cache/litespeed-cache.php') && get_option('a2_cache_enabled') != 1) {
     
    329325        return $result;
    330326    }
    331    
     327
    332328    /**
    333329     * Check if PHP OpCache is enabled
     
    336332     */
    337333    public function a2opt_phpopcache_test() {
    338         $result = array(
     334        $result = [
    339335            'label' => __( 'PHP OpCaching is enabled' ),
    340336            'status' => 'good', // Default "passing" section
    341             'badge' => array(
    342                 'label' => __( 'Performance' ),
    343                 'color' => 'orange',
    344             ),
     337            'badge' => [
     338                'label' => __( 'Performance' ),
     339                'color' => 'orange',
     340            ],
    345341            'description' => sprintf(
    346342                '<p>%s</p>',
     
    349345            'actions' => '',
    350346            'test' => 'opcaching_enabled',
    351         );
    352 
    353         if(function_exists('opcache_get_status')){
     347        ];
     348
     349        if (function_exists('opcache_get_status')) {
    354350            $opcache_status = opcache_get_status();
    355351        } else {
    356352            $opcache_status = false;
    357         };
     353        }
    358354
    359355        if (!is_array($opcache_status) || !$opcache_status['opcache_enabled']) {
     
    368364        return $result;
    369365    }
    370    
     366
    371367    /**
    372368     * Check if other caching plugins are enabled
     
    375371     */
    376372    public function a2opt_other_cache_test() {
    377         $result = array(
     373        $result = [
    378374            'label' => __( 'No conflicting cache plugins detected' ),
    379375            'status' => 'good', // Default "passing" section
    380             'badge' => array(
    381                 'label' => __( 'Performance' ),
    382                 'color' => 'orange',
    383             ),
     376            'badge' => [
     377                'label' => __( 'Performance' ),
     378                'color' => 'orange',
     379            ],
    384380            'description' => sprintf(
    385381                '<p>%s</p>',
     
    388384            'actions' => '',
    389385            'test' => 'caching_enabled',
    390         );
     386        ];
    391387
    392388        $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
    406394        $found_plugin = false;
    407        
     395
    408396        foreach ($active_plugins as $active_plugin) {
    409397            $plugin_folder = explode('/', $active_plugin);
     
    429417        return $result;
    430418    }
    431    
     419
    432420    /**
    433421     * Check PHP Memory limits
     
    436424     */
    437425    public function a2opt_php_memory_test() {
    438         $result = array(
     426        $result = [
    439427            'label' => __( 'PHP has good memory limits' ),
    440428            'status' => 'good', // Default "passing" section
    441             'badge' => array(
    442                 'label' => __( 'Performance' ),
    443                 'color' => 'orange',
    444             ),
     429            'badge' => [
     430                'label' => __( 'Performance' ),
     431                'color' => 'orange',
     432            ],
    445433            'description' => sprintf(
    446434                '<p>%s</p>',
     
    449437            'actions' => '',
    450438            'test' => 'php_memory',
    451         );
     439        ];
    452440
    453441        $memory_limit = $this->return_bytes(ini_get('memory_limit'));
     
    463451        return $result;
    464452    }
    465    
     453
    466454    /**
    467455     * Check number of unused plugins
     
    470458     */
    471459    public function a2opt_plugin_count_test() {
    472         $result = array(
     460        $result = [
    473461            'label' => __( 'Large number of unused plugins' ),
    474462            'status' => 'good', // Default "passing" section
    475             'badge' => array(
    476                 'label' => __( 'Performance' ),
    477                 'color' => 'orange',
    478             ),
     463            'badge' => [
     464                'label' => __( 'Performance' ),
     465                'color' => 'orange',
     466            ],
    479467            'description' => sprintf(
    480468                '<p>%s</p>',
     
    483471            'actions' => '',
    484472            'test' => 'plugin_count',
    485         );
     473        ];
    486474
    487475        $plugins = get_plugins();
     
    501489        return $result;
    502490    }
    503    
     491
    504492    /**
    505493     * Check number of unused themes
     
    508496     */
    509497    public function a2opt_theme_count_test() {
    510         $result = array(
     498        $result = [
    511499            'label' => __( 'Large number of unused themes' ),
    512500            'status' => 'good', // Default "passing" section
    513             'badge' => array(
    514                 'label' => __( 'Performance' ),
    515                 'color' => 'orange',
    516             ),
     501            'badge' => [
     502                'label' => __( 'Performance' ),
     503                'color' => 'orange',
     504            ],
    517505            'description' => sprintf(
    518506                '<p>%s</p>',
     
    521509            'actions' => '',
    522510            'test' => 'theme_count',
    523         );
     511        ];
    524512
    525513        $themes = wp_get_themes();
     
    540528        return $result;
    541529    }
    542    
     530
    543531    /**
    544532     * Check if Cart Fragment AJAX calls are dequeued
     
    547535     */
    548536    public function a2opt_cart_fragments_test() {
    549         $result = array(
     537        $result = [
    550538            'label' => __( 'Dequeue WooCommerce Cart Fragments AJAX calls' ),
    551539            'status' => 'good', // Default "passing" section
    552             'badge' => array(
    553                 'label' => __( 'Performance' ),
    554                 'color' => 'orange',
    555             ),
     540            'badge' => [
     541                'label' => __( 'Performance' ),
     542                'color' => 'orange',
     543            ],
    556544            'description' => sprintf(
    557545                '<p>%s</p>',
     
    560548            'actions' => '',
    561549            'test' => 'cart_fragments',
    562         );
     550        ];
    563551
    564552        if (!get_option('a2_wc_cart_fragments')) {
     
    568556        return $result;
    569557    }
    570    
     558
    571559    /**
    572560     * Check if GZIP compression is enabled
     
    575563     */
    576564    public function a2opt_gzip_test() {
    577         $result = array(
     565        $result = [
    578566            'label' => __( 'You should enable GZIP compression' ),
    579567            'status' => 'recommended', // Default "failing" section
    580             'badge' => array(
    581                 'label' => __( 'Performance' ),
    582                 'color' => 'orange',
    583             ),
     568            'badge' => [
     569                'label' => __( 'Performance' ),
     570                'color' => 'orange',
     571            ],
    584572            'description' => sprintf(
    585573                '<p>%s</p>',
     
    588576            'actions' => '',
    589577            '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')) {
    593581            $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']) {
    596583            $result['status'] = 'good';
    597584        }
     
    599586        return $result;
    600587    }
    601    
     588
    602589    /**
    603590     * Check if XML-RPC requests are blocked
     
    606593     */
    607594    public function a2opt_xml_rpc_test() {
    608         $result = array(
     595        $result = [
    609596            'label' => __( 'Block Unauthorized XML-RPC Requests' ),
    610597            'status' => 'good', // Default "passing" section
    611             'badge' => array(
    612                 'label' => __( 'Performance' ),
    613                 'color' => 'orange',
    614             ),
     598            'badge' => [
     599                'label' => __( 'Performance' ),
     600                'color' => 'orange',
     601            ],
    615602            'description' => sprintf(
    616603                '<p>%s</p>',
     
    619606            'actions' => '',
    620607            'test' => 'block_xmlrpc',
    621         );
     608        ];
    622609
    623610        if (!get_option('a2_block_xmlrpc')) {
     
    634621     */
    635622    public function a2opt_file_edit_test() {
    636         $result = array(
     623        $result = [
    637624            'label' => __( 'Lock Editing of Plugins and Themes from the WP Admin' ),
    638625            'status' => 'good', // Default "passing" section
    639             'badge' => array(
    640                 'label' => __( 'Performance' ),
    641                 'color' => 'orange',
    642             ),
     626            'badge' => [
     627                'label' => __( 'Performance' ),
     628                'color' => 'orange',
     629            ],
    643630            'description' => sprintf(
    644631                '<p>%s</p>',
     
    647634            'actions' => '',
    648635            'test' => 'file_edit',
    649         );
     636        ];
    650637
    651638        if (!get_option('a2_optimized_lockdown')) {
     
    655642        return $result;
    656643    }
    657    
     644
    658645    /**
    659646     * Add A2 Optimized section to Info tab.
     
    664651     */
    665652    public function add_debug_section($debug_info) {
    666         $a2_optimized = array(
     653        $a2_optimized = [
    667654            'label' => 'A2Optimized',
    668             'fields' => array(
    669                 'version' => array(
     655            'fields' => [
     656                'version' => [
    670657                    'label' => 'Version',
    671658                    'value' => A2OPT_FULL_VERSION,
    672                 ),
    673             ),
    674         );
    675        
     659                ],
     660            ],
     661        ];
     662
    676663        /* MySQL Version */
    677664        global $wpdb;
    678665        $mysqlVersion = $wpdb->db_version();
    679666
    680         $a2_optimized['fields']['mysql_version'] = array(
     667        $a2_optimized['fields']['mysql_version'] = [
    681668            'label' => 'MySQL Version',
    682669            'value' => $mysqlVersion
    683         );
     670        ];
    684671
    685672        /* PHP Version */
    686         $a2_optimized['fields']['php_version'] = array(
     673        $a2_optimized['fields']['php_version'] = [
    687674            'label' => 'PHP Version',
    688675            'value' => phpversion()
    689         );
    690        
     676        ];
     677
    691678        /* CPU Info */
    692         if(function_exists('exec')){
     679        if (function_exists('exec')) {
    693680            $cpu_info = exec('cat /proc/cpuinfo | grep "model name\\|processor"');
    694681            $cpu_info = str_replace('model name', '', $cpu_info);
    695682            $cpu_info = str_replace('processor', '', $cpu_info);
    696683            $cpu_info = str_replace(':', '', $cpu_info);
    697             $a2_optimized['fields']['cpu_info'] = array(
     684            $a2_optimized['fields']['cpu_info'] = [
    698685                'label' => 'CPU Info',
    699686                'value' => $cpu_info
    700             );
    701         };
    702    
     687            ];
     688        }
     689
    703690        /* Webserver info */
    704         $a2_optimized['fields']['http_server'] = array(
     691        $a2_optimized['fields']['http_server'] = [
    705692            'label' => 'Web Server',
    706693            'value' => php_sapi_name()
    707         );
    708        
     694        ];
     695
    709696        /* PHP Memory Limit */
    710         $a2_optimized['fields']['php_memory'] = array(
     697        $a2_optimized['fields']['php_memory'] = [
    711698            'label' => 'PHP Memory Limit',
    712699            'value' => ini_get('memory_limit')
    713         );
    714        
     700        ];
     701
    715702        /* 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'] = [
    719706                'label' => 'Frontend Benchmark',
    720707                'value' => 'Test not run yet'
    721             );
     708            ];
    722709        } else {
    723710            $frontend_benchmarks_last = array_pop($frontend_benchmarks);
    724711
    725             $a2_optimized['fields']['benchmark_frontend_overall'] = array(
     712            $a2_optimized['fields']['benchmark_frontend_overall'] = [
    726713                'label' => 'Frontend Benchmark Overall Score',
    727714                'value' => $frontend_benchmarks_last['scores']['overall_score']
    728             );
    729             $a2_optimized['fields']['benchmark_frontend_fcp'] = array(
     715            ];
     716            $a2_optimized['fields']['benchmark_frontend_fcp'] = [
    730717                'label' => 'Frontend Benchmark FCP',
    731718                'value' => $frontend_benchmarks_last['scores']['fcp']
    732             );
    733             $a2_optimized['fields']['benchmark_frontend_ttfb'] = array(
     719            ];
     720            $a2_optimized['fields']['benchmark_frontend_ttfb'] = [
    734721                'label' => 'Frontend Benchmark TTFB',
    735722                'value' => $frontend_benchmarks_last['scores']['ttfb']
    736             );
    737             $a2_optimized['fields']['benchmark_frontend_lcp'] = array(
     723            ];
     724            $a2_optimized['fields']['benchmark_frontend_lcp'] = [
    738725                'label' => 'Frontend Benchmark LCP',
    739726                'value' => $frontend_benchmarks_last['scores']['lcp']
    740             );
    741             $a2_optimized['fields']['benchmark_frontend_fid'] = array(
     727            ];
     728            $a2_optimized['fields']['benchmark_frontend_fid'] = [
    742729                'label' => 'Frontend Benchmark FID',
    743730                'value' => $frontend_benchmarks_last['scores']['fid']
    744             );
    745             $a2_optimized['fields']['benchmark_frontend_cls'] = array(
     731            ];
     732            $a2_optimized['fields']['benchmark_frontend_cls'] = [
    746733                'label' => 'Frontend Benchmark CLS',
    747734                'value' => $frontend_benchmarks_last['scores']['cls']
    748             );
    749         }
    750        
     735            ];
     736        }
     737
    751738        /* Backend Benchmarks */
    752739        $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'] = [
    755742                'label' => 'Hosting Benchmark',
    756743                'value' => 'Test not run yet'
    757             );
     744            ];
    758745        } else {
    759746            $backend_benchmarks_last = array_pop($backend_benchmarks);
    760             $a2_optimized['fields']['benchmark_hosting_overall'] = array(
     747            $a2_optimized['fields']['benchmark_hosting_overall'] = [
    761748                'label' => 'Hosting Benchmark Overall Score',
    762749                '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'] = [
    765752                'label' => 'Hosting Benchmark PHP Score',
    766753                'value' => $backend_benchmarks_last['php']['total']
    767             );
    768             $a2_optimized['fields']['benchmark_hosting_mysql'] = array(
     754            ];
     755            $a2_optimized['fields']['benchmark_hosting_mysql'] = [
    769756                'label' => 'Hosting Benchmark MySQL Score',
    770757                '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'] = [
    773760                'label' => 'Hosting Benchmark Filesystem Score',
    774761                'value' => $backend_benchmarks_last['filesystem']
    775             );
     762            ];
    776763        }
    777764
     
    790777    private function return_bytes($val) {
    791778        $val = trim($val);
    792         $last = strtolower($val[strlen($val)-1]);
     779        $last = strtolower($val[strlen($val) - 1]);
    793780        $val = substr($val, 0, -1);
    794         switch($last) {
     781        switch ($last) {
    795782            case 'g':
    796783                $val *= 1024;
     784                // no break
    797785            case 'm':
    798786                $val *= 1024;
     787                // no break
    799788            case 'k':
    800789                $val *= 1024;
    801790        }
     791
    802792        return $val;
    803793    }
  • a2-optimized-wp/tags/3.0.7/readme.txt

    r2984569 r2996487  
    33Tags: a2 hosting, cache, caching, speed, fast, optimize, site performance, image optimization, image compression, site security, seo, gzip compression, minify code, code minification
    44Requires at least: 5.1
    5 Tested up to: 6.4
    6 Stable tag: 3.0.6.6
     5Tested up to: 6.4.1
     6Stable tag: 3.0.7
    77Requires PHP: 5.6
    88License: GPLv3
     
    153153== Changelog ==
    154154
     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
    155159= 3.0.6.6 =
    156160* Tested with WordPress 6.4
Note: See TracChangeset for help on using the changeset viewer.