Plugin Directory

Changeset 2954507


Ignore:
Timestamp:
08/16/2023 03:42:31 PM (3 years ago)
Author:
a2hosting
Message:

v3.0.6.4.2

Location:
a2-optimized-wp/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • a2-optimized-wp/trunk/a2-optimized.php

    r2929752 r2954507  
    1010 * Plugin Name: A2 Optimized WP
    1111 * Plugin URI: https://wordpress.org/plugins/a2-optimized/
    12  * Version: 3.0.6.4.1
     12 * Version: 3.0.6.4.2
    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.4.1' );
     27define( 'A2OPT_FULL_VERSION', '3.0.6.4.2' );
    2828define( 'A2OPT_MIN_PHP', '5.6' );
    2929define( 'A2OPT_MIN_WP', '5.1' );
  • a2-optimized-wp/trunk/core/A2_Optimized_Benchmark.php

    r2914399 r2954507  
    3131        // Do the needful
    3232    }
    33    
     33
    3434    /**
    3535     * Run all hosting benchmark tests and store results
    36      * 
     36     *
    3737     * @return array $results[] An array of benchmark results
    3838     */
     
    4040    public function run_hosting_test_suite($result_desc = null) {
    4141        $existing_results = [];
    42        
    43         try{
     42
     43        try {
    4444            $results = [];
    4545            $results['version'] = A2OPT_FULL_VERSION;
    46             $results['sysinfo']['time'] = date("Y-m-d H:i:s");
     46            $results['sysinfo']['time'] = date('Y-m-d H:i:s');
    4747            $results['sysinfo']['php_version'] = PHP_VERSION;
    4848            $results['sysinfo']['platform'] = PHP_OS;
     
    7070
    7171            update_option('a2opt-benchmarks-hosting', $existing_results);
     72
    7273            return [
    7374                'status' => 'success',
     
    7576                'data' => $results
    7677            ];
    77         } catch (Exception $ex){
     78        } catch (Exception $ex) {
    7879            return [
    7980                'status' => 'error',
     
    8586    /**
    8687     * Run all PHP benchmark tests
    87      * 
     88     *
    8889     * @return array $results[] An array of benchmark results
    8990     */
     
    108109     * Run Math PHP benchmark tests
    109110     *
    110      * @param float $multiplier Multiplier for number of times to run test 
    111      * @return string Time taken for test 
    112      */
    113     private function test_php_math($multiplier = 1.0){
     111     * @param float $multiplier Multiplier for number of times to run test
     112     * @return string Time taken for test
     113     */
     114    private function test_php_math($multiplier = 1.0) {
    114115        $count = 150000 * $multiplier;
    115116        $time_start = microtime(true);
     
    137138     * Run string manipulation PHP benchmark tests
    138139     *
    139      * @param float $multiplier Multiplier for number of times to run test 
    140      * @return string Time taken for test 
    141      */
    142     private function test_php_string($multiplier = 1.0){
     140     * @param float $multiplier Multiplier for number of times to run test
     141     * @return string Time taken for test
     142     */
     143    private function test_php_string($multiplier = 1.0) {
    143144        $count = 150000 * $multiplier;
    144145        $time_start = microtime(true);
     
    158159            ord($string);
    159160        }
     161
    160162        return $this->timer_diff($time_start);
    161163    }
     
    164166     * Run Loop PHP benchmark tests
    165167     *
    166      * @param float $multiplier Multiplier for number of times to run test 
    167      * @return string Time taken for test 
    168      */
    169     private function test_php_loops($multiplier = 1.0){
     168     * @param float $multiplier Multiplier for number of times to run test
     169     * @return string Time taken for test
     170     */
     171    private function test_php_loops($multiplier = 1.0) {
    170172        $count = 50000000 * $multiplier;
    171173        $time_start = microtime(true);
     
    183185     * Run If/Else PHP benchmark tests
    184186     *
    185      * @param float $multiplier Multiplier for number of times to run test 
    186      * @return string Time taken for test 
    187      */
    188     private function test_php_ifelse($multiplier = 1.0){
     187     * @param float $multiplier Multiplier for number of times to run test
     188     * @return string Time taken for test
     189     */
     190    private function test_php_ifelse($multiplier = 1.0) {
    189191        $count = 50000000 * $multiplier;
    190192        $time_start = microtime(true);
    191193        for ($i = 0; $i < $count; $i++) {
    192194            if ($i == -1) {
    193 
    194195            } elseif ($i == -2) {
    195 
    196             } else if ($i == -3) {
    197 
    198             }
    199         }
     196            } elseif ($i == -3) {
     197            }
     198        }
     199
    200200        return $this->timer_diff($time_start);
    201201    }
     
    203203    /**
    204204     * Delete benchmarking records
    205      * 
     205     *
    206206     * @param string $benchmarks_type frontend or backend
    207207     * @param int $items Number of items to keep; defaults to 25, constrained to [0-25]
     
    209209     */
    210210    public function prune_benchmarks($benchmarks_type, $items = 25) {
    211         if ($benchmarks_type != 'frontend' && $benchmarks_type != 'backend') return;
     211        if ($benchmarks_type != 'frontend' && $benchmarks_type != 'backend') {
     212            return;
     213        }
    212214        $items = $this->constrain($items, 0, 25);
    213215
    214216        $benchmarks = [];
    215         if ($benchmarks_type == 'frontend') $benchmarks = get_option('a2opt-benchmarks-frontend');
    216         elseif ($benchmarks_type == 'backend') $benchmarks = get_option('a2opt-benchmarks-hosting');
    217         if (empty($benchmarks)) return;
     217        if ($benchmarks_type == 'frontend') {
     218            $benchmarks = get_option('a2opt-benchmarks-frontend');
     219        } elseif ($benchmarks_type == 'backend') {
     220            $benchmarks = get_option('a2opt-benchmarks-hosting');
     221        }
     222        if (empty($benchmarks)) {
     223            return;
     224        }
    218225
    219226        $items_to_delete = count($benchmarks) - $items;
    220         if ($items_to_delete < 1) return;
     227        if ($items_to_delete < 1) {
     228            return;
     229        }
    221230        $items_deleted = 0;
    222231
     
    224233            unset($benchmarks[$date]);
    225234            ++$items_deleted;
    226             if ($items_deleted >= $items_to_delete) break;
    227         }
    228 
    229         if ($benchmarks_type == 'frontend') update_option('a2opt-benchmarks-frontend', $benchmarks);
    230         elseif ($benchmarks_type == 'backend') update_option('a2opt-benchmarks-hosting', $benchmarks);
     235            if ($items_deleted >= $items_to_delete) {
     236                break;
     237            }
     238        }
     239
     240        if ($benchmarks_type == 'frontend') {
     241            update_option('a2opt-benchmarks-frontend', $benchmarks);
     242        } elseif ($benchmarks_type == 'backend') {
     243            update_option('a2opt-benchmarks-hosting', $benchmarks);
     244        }
    231245    }
    232246
    233247    /**
    234248     * Private helper function to constrain a float to a range of values
    235      * 
     249     *
    236250     * @param float $value The value to constrain
    237251     * @param float $min   The minimum value for the value (inclusive)
     
    246260            $value = $min;
    247261        }
     262
    248263        return $value;
    249264    }
     
    252267     * Run MySQL benchmark tests
    253268     *
    254      * @param int $count Optional number of times to run test 
    255      * @return string Time taken for test 
    256      */
    257     public function run_mysql_benchmarks($count = 1){
     269     * @param int $count Optional number of times to run test
     270     * @return string Time taken for test
     271     */
     272    public function run_mysql_benchmarks($count = 1) {
    258273        $results = [];
    259274
     
    262277        $wpdb_cfg['db.user'] = DB_USER;
    263278        $wpdb_cfg['db.pw'] = DB_PASSWORD;
    264         $wpdb_cfg['db.name'] = DB_NAME; 
     279        $wpdb_cfg['db.name'] = DB_NAME;
    265280
    266281        $time_start = microtime(true);
    267282
    268283        //detect socket connection
    269         if(stripos($wpdb_cfg['db.host'], '.sock')!==false){
     284        if (stripos($wpdb_cfg['db.host'], '.sock') !== false) {
    270285            //parse socket location
    271286            //set a default guess
    272             $socket = "/var/lib/mysql.sock";
     287            $socket = '/var/lib/mysql.sock';
    273288            $serverhost = explode(':', $wpdb_cfg['db.host']);
    274             if(count($serverhost) == 2 && $serverhost[0] == 'localhost'){
     289            if (count($serverhost) == 2 && $serverhost[0] == 'localhost') {
    275290                $socket = $serverhost[1];
    276291            }
     
    279294            //parse out port number if exists
    280295            $port = 3306;//default
    281             if(stripos($wpdb_cfg['db.host'],':')){
    282                 $port = substr($wpdb_cfg['db.host'], stripos($wpdb_cfg['db.host'],':')+1);
    283                 $wpdb_cfg['db.host'] = substr($wpdb_cfg['db.host'], 0, stripos($wpdb_cfg['db.host'],':'));
     296            if (stripos($wpdb_cfg['db.host'], ':')) {
     297                $port = substr($wpdb_cfg['db.host'], stripos($wpdb_cfg['db.host'], ':') + 1);
     298                $wpdb_cfg['db.host'] = substr($wpdb_cfg['db.host'], 0, stripos($wpdb_cfg['db.host'], ':'));
    284299            }
    285300            $link = mysqli_connect($wpdb_cfg['db.host'], $wpdb_cfg['db.user'], $wpdb_cfg['db.pw'], $wpdb_cfg['db.name'], $port);
     
    308323     * Run WordPress DB benchmark tests
    309324     *
    310      * @param int $count Optional number of times to run test 
    311      * @return array Time taken for test and number of queries per second 
    312      */
    313     public function run_wordpress_benchmarks($count = 500){
     325     * @param int $count Optional number of times to run test
     326     * @return array Time taken for test and number of queries per second
     327     */
     328    public function run_wordpress_benchmarks($count = 500) {
    314329        global $wpdb;
    315330
    316331        // dummy text to insert into database
    317         $dummytextseed = "Sed tincidunt malesuada viverra. Aliquam dolor diam, interdum quis mauris eget, accumsan imperdiet nisi. Proin mattis massa sapien, et tempor enim lacinia suscipit. Donec at massa ullamcorper, pellentesque lacus sit amet, facilisis metus. Proin lobortis elementum lorem eu volutpat. Aenean sed volutpat augue. Morbi vel dolor commodo, tempor ex ac, hendrerit ante. Vestibulum pellentesque fringilla ligula ac aliquet. Cras tempus enim nec imperdiet convallis. Aliquam elit ex, ornare vestibulum placerat quis, tincidunt ultrices dolor. Morbi gravida sapien congue leo sagittis, sed semper turpis blandit. Aenean malesuada eros vitae orci tristique, vitae imperdiet libero mollis. Nunc lacinia congue tempor. Etiam vitae enim ut eros fermentum elementum. Praesent aliquam iaculis velit, quis dictum nibh.";
    318         $dummytext = "";
    319         for($x=0; $x<100; $x++){
     332        $dummytextseed = 'Sed tincidunt malesuada viverra. Aliquam dolor diam, interdum quis mauris eget, accumsan imperdiet nisi. Proin mattis massa sapien, et tempor enim lacinia suscipit. Donec at massa ullamcorper, pellentesque lacus sit amet, facilisis metus. Proin lobortis elementum lorem eu volutpat. Aenean sed volutpat augue. Morbi vel dolor commodo, tempor ex ac, hendrerit ante. Vestibulum pellentesque fringilla ligula ac aliquet. Cras tempus enim nec imperdiet convallis. Aliquam elit ex, ornare vestibulum placerat quis, tincidunt ultrices dolor. Morbi gravida sapien congue leo sagittis, sed semper turpis blandit. Aenean malesuada eros vitae orci tristique, vitae imperdiet libero mollis. Nunc lacinia congue tempor. Etiam vitae enim ut eros fermentum elementum. Praesent aliquam iaculis velit, quis dictum nibh.';
     333        $dummytext = '';
     334        for ($x=0; $x < 100; $x++) {
    320335            $dummytext .= str_shuffle($dummytextseed);
    321336        }
     
    325340        $table = $wpdb->prefix . 'options';
    326341        $optionname = 'a2opt_benchmark_';
    327         for($x=0; $x<$count;$x++){
     342        for ($x=0; $x < $count;$x++) {
    328343            //insert
    329             $data = array('option_name' => $optionname . $x, 'option_value' => $dummytext);
     344            $data = ['option_name' => $optionname . $x, 'option_value' => $dummytext];
    330345            $wpdb->insert($table, $data);
    331346            //select
     
    333348            $wpdb->get_var($select);
    334349            //update
    335             $data = array('option_value' => $dummytextseed);
    336             $where =  array('option_name' => $optionname . $x);
     350            $data = ['option_value' => $dummytextseed];
     351            $where =  ['option_name' => $optionname . $x];
    337352            $wpdb->update($table, $data, $where);
    338353            //delete
    339             $where = array('option_name'=>$optionname.$x);
    340             $wpdb->delete($table,$where);   
     354            $where = ['option_name'=>$optionname . $x];
     355            $wpdb->delete($table, $where);
    341356        }
    342357
    343358        $time = $this->timer_diff($time_start);
    344359        $queries = ($count * 4) / $time;
     360
    345361        return [
    346362            'time' => $time,
    347363            'queries_per_second' => $queries,
    348         ];     
     364        ];
    349365    }
    350366
     
    352368     * Run filesystem benchmark tests
    353369     *
    354      * @param int $count Optional number of times to run test 
    355      * @return array Time taken for test and number of queries per second 
    356      */
    357     public function run_filesystem_benchmarks($count = 1){
     370     * @param int $count Optional number of times to run test
     371     * @return array Time taken for test and number of queries per second
     372     */
     373    public function run_filesystem_benchmarks($count = 1) {
    358374        // Make sure tmp folder is empty and we can write to it
    359         if(!$this->clean_tmp_folder()){
     375        if (!$this->clean_tmp_folder()) {
    360376            return false;
    361         };
    362        
    363         $time_start = microtime(true);
    364        
    365         $write_content = "";
    366        
     377        }
     378
     379        $time_start = microtime(true);
     380
     381        $write_content = '';
     382
    367383        // Get 1mb of data
    368         for($m=0; $m < 1024; $m++){
     384        for ($m=0; $m < 1024; $m++) {
    369385            $write_content .= $this->get_1kb_text();
    370386        }
    371387
    372         $fn = $this->tmp_folder_name . "/tmp.filewrite";
    373 
    374         for($i=0; $i < $count; $i++) {
    375 
    376             if(file_exists($fn)) {
     388        $fn = $this->tmp_folder_name . '/tmp.filewrite';
     389
     390        for ($i=0; $i < $count; $i++) {
     391            if (file_exists($fn)) {
    377392                unlink($fn);
    378393                clearstatcache();
    379394            }
    380395
    381             $fp = fopen($fn, "w");
     396            $fp = fopen($fn, 'w');
    382397
    383398            // Write 50mb
    384             for($k=0; $k < 50; $k++){
    385                 if($this->timer_diff($time_start) > 10){
     399            for ($k=0; $k < 50; $k++) {
     400                if ($this->timer_diff($time_start) > 10) {
    386401                    // If this is taking more than 10 seconds, we're being throttled, just bail
    387402                    fclose($fp);
    388403                    clearstatcache();
    389404                    $this->clean_tmp_folder();
     405
    390406                    return 10;
    391407                }
    392                
     408
    393409                fwrite($fp, $write_content);
    394410            }
     
    406422    /**
    407423     * Filter out the data being returned by lighthouse down to only the data that we actually care about.
    408      * 
     424     *
    409425     * @param array array of data that's been returned from lighthouse api call
    410426     * @return array filtered array of only the data that we want to store
    411427     */
    412     private function filter_lighthouse_data($lighthouse_data){
    413 
     428    private function filter_lighthouse_data($lighthouse_data) {
    414429        $scores = [];
    415430
    416         foreach($lighthouse_data['lighthouseResult']['categories'] as $group) {
    417             foreach($group['auditRefs'] as $ref){
     431        foreach ($lighthouse_data['lighthouseResult']['categories'] as $group) {
     432            foreach ($group['auditRefs'] as $ref) {
    418433                if ('server-response-time' === $ref['id']) {
    419434                    $scores['ttfb'] = round( $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue'] );
     
    423438                    $scores['fcp'] = $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue'];
    424439                }
    425                
     440
    426441                if ( 'cumulative-layout-shift' === $ref['id'] ) {
    427442                    $scores['cls'] = $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue'];
    428443                }
    429            
     444
    430445                if ( 'largest-contentful-paint' === $ref['id'] ) {
    431446                    $scores['lcp'] = $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue'];
    432447                }
    433                
     448
    434449                if ( 'max-potential-fid' === $ref['id'] ) {
    435450                    $scores['fid'] = $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue'];
     
    438453        }
    439454
    440         foreach($this->get_seo_audits() as $audit){
    441             if(isset($lighthouse_data['lighthouseResult']['audits'][$audit])){
     455        foreach ($this->get_seo_audits() as $audit) {
     456            if (isset($lighthouse_data['lighthouseResult']['audits'][$audit])) {
    442457                $scores['audit_result'][$audit] = $lighthouse_data['lighthouseResult']['audits'][$audit];
    443458            }
     
    449464    }
    450465
    451 
    452466    /**
    453467     * Get Lighthouse results
    454468     *
    455      * @param string $strategy Desktop or Mobile 
    456      * @return array $results Array containing the results of the test 
    457      */
    458     public function get_lighthouse_results($strategy = "desktop", $retry_count = 3, $result_desc = null){
     469     * @param string $strategy Desktop or Mobile
     470     * @return array $results Array containing the results of the test
     471     */
     472    public function get_lighthouse_results($strategy = 'desktop', $retry_count = 3, $result_desc = null) {
    459473        $output = [];
    460    
     474
    461475        $url = 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=' . get_site_url() . '&strategy=' . $strategy;
    462476        $pagespeed_options = get_option('a2opt-pagespeed');
    463         if($pagespeed_options && isset($pagespeed_options['api-key'])){
     477        if ($pagespeed_options && isset($pagespeed_options['api-key'])) {
    464478            $url .= '&key=' . $pagespeed_options['api-key'];
    465479        }
    466480        $response = wp_remote_get($url, ['timeout' => 45]);
    467         if(is_array($response) && !is_wp_error($response)){
     481        if (is_array($response) && !is_wp_error($response)) {
    468482            $lighthouse_data = json_decode($response['body'], true);
    469             if(!isset($lighthouse_data['error']) || empty($lighthouse_data['error'])){
     483            if (!isset($lighthouse_data['error']) || empty($lighthouse_data['error'])) {
    470484                // success
    471485                $option_key = 'a2opt-benchmarks-frontend';
    472486                $existing_results = get_option($option_key);
    473                 if(!$existing_results){
     487                if (!$existing_results) {
    474488                    $existing_results = [];
    475489                }
    476                
     490
    477491                $existing_results[date('Y-m-d H:i:s')] = [
    478492                    'strategy' => $strategy,
     
    488502            } else {
    489503                $error_code = $lighthouse_data['error']['code'];
    490                 if (in_array($error_code, [500,400]) || $retry_count <= 0){
     504                if (in_array($error_code, [500,400]) || $retry_count <= 0) {
    491505                    $error_msg = '';
    492                     if(isset($lighthouse_data['error']['message'])){
     506                    if (isset($lighthouse_data['error']['message'])) {
    493507                        $error_msg = $lighthouse_data['error']['message'];
    494508                    }
     
    497511                        'message' => 'There was an error retrieving results from Pagespeed. ' . $error_msg,
    498512                    ];
    499                 }
    500                 else {
     513                } else {
    501514                    $output = $this->get_lighthouse_results($strategy, --$retry_count, $result_desc);
    502515                }
    503             };
     516            }
    504517        } else {
    505518            $output = [
     
    512525    }
    513526
    514 
    515     private function get_seo_audits(){
     527    private function get_seo_audits() {
    516528        $audits = [
    517529            'first-contentful-paint',
     
    558570            'uses-long-cache-ttl'
    559571        ];
    560        
     572
    561573        return $audits;
    562574    }
    563575
    564 
    565576    /**
    566577     * Time elapsed since the passed in time
    567578     *
    568      * @param string $time_start timestamp 
    569      * @return string Time elapsed in seconds 
    570      */
    571     private function timer_diff($time_start){
     579     * @param string $time_start timestamp
     580     * @return string Time elapsed in seconds
     581     */
     582    private function timer_diff($time_start) {
    572583        return number_format(microtime(true) - $time_start, 3);
    573584    }
     
    576587     * 1kb of text to build out file operations
    577588     *
    578      * @return string The blob of text 
     589     * @return string The blob of text
    579590     */
    580591    private function get_1kb_text() {
    581         return("AAA2A2A222222AAAA2AAA2AA22A222AA22AAA22A2A22AAA222A22A2A2A2AA22222AAAAAAA22A222AAA22AAAAA222AA2AAA22A2A2AA22AA2A2222A22AAAA2AAA2A222222AA22AAAA2A2A2AA2222A2A2AA2A2AAAA2AA222A222A22AAA22AA2AA22AA22AAA2AA2A22A222222A2AA2A222A22A22A2A2AAAA222A2A2A2A2AAAA2A22AA22AAA2A2AAA2A222A2AAAA2AA22A2AA222A222AA22222222AAAAA2A22A2AA22A2AAAAA2AAAAAA2AAAA22AAAA22A2AAAAAA2AA2A22A22AA2AA22A2AA2AAA2A2A22A222AA2AAAA22A2A2AAAA2AA2A2A22A2A2A2AA222AA22AAA2AAAAA2AA2A2A2A22AAA222A22AA22AA2A222A222AA2AAAA2222A2AA22AA2A22AAAA2AA222A2AAA22AA22A2AA2AA22A222AA2AAA22A2A222A2A2222A2A2222AAAAA2A222AA22A2A2A2222AAAA2AA22AAAA2AA2AAAAAAA22AAAA2AA2AA2A2A2AAAAAA22AA222AAAA2AAAA22AA222222A2AA222A22A2AA2A22222A2A2A2AA222222A2A222AAA2AA2A2A222A22222AAAAA2A2A22AAAAAA2A2A222A2AA2AAAA222AAAA2A22A222A2A2A2A2AA222AA2A2AA2A222AA2A2A2A22222A22A2A2A2AA2A2A2222A2222A2AAA2A2222AA222A22222222AA2AA222AA2AAAA2AA2AA22A2AA22AA2222A22A222AA2A2A22222AAA2A2A2A2AAAAAAA2222AA2222AA2222A2AAAA22AA2A2A2A2A22A2AAAAAAA222A22A22AA2AAA2AA222AA22A2AAAAA2A2AAA2AA22AA2A222AAA222A2");
     592        return('AAA2A2A222222AAAA2AAA2AA22A222AA22AAA22A2A22AAA222A22A2A2A2AA22222AAAAAAA22A222AAA22AAAAA222AA2AAA22A2A2AA22AA2A2222A22AAAA2AAA2A222222AA22AAAA2A2A2AA2222A2A2AA2A2AAAA2AA222A222A22AAA22AA2AA22AA22AAA2AA2A22A222222A2AA2A222A22A22A2A2AAAA222A2A2A2A2AAAA2A22AA22AAA2A2AAA2A222A2AAAA2AA22A2AA222A222AA22222222AAAAA2A22A2AA22A2AAAAA2AAAAAA2AAAA22AAAA22A2AAAAAA2AA2A22A22AA2AA22A2AA2AAA2A2A22A222AA2AAAA22A2A2AAAA2AA2A2A22A2A2A2AA222AA22AAA2AAAAA2AA2A2A2A22AAA222A22AA22AA2A222A222AA2AAAA2222A2AA22AA2A22AAAA2AA222A2AAA22AA22A2AA2AA22A222AA2AAA22A2A222A2A2222A2A2222AAAAA2A222AA22A2A2A2222AAAA2AA22AAAA2AA2AAAAAAA22AAAA2AA2AA2A2A2AAAAAA22AA222AAAA2AAAA22AA222222A2AA222A22A2AA2A22222A2A2A2AA222222A2A222AAA2AA2A2A222A22222AAAAA2A2A22AAAAAA2A2A222A2AA2AAAA222AAAA2A22A222A2A2A2A2AA222AA2A2AA2A222AA2A2A2A22222A22A2A2A2AA2A2A2222A2222A2AAA2A2222AA222A22222222AA2AA222AA2AAAA2AA2AA22A2AA22AA2222A22A222AA2A2A22222AAA2A2A2A2AAAAAAA2222AA2222AA2222A2AAAA22AA2A2A2A2A22A2AAAAAAA222A22A22AA2AAA2AA222AA22A2AAAAA2A2AAA2AA22AA2A222AAA222A2');
    582593    }
    583594
     
    588599        $tmp_folder = $this->tmp_folder_name;
    589600        if (!is_dir($tmp_folder)) {
    590             if (!mkdir($tmp_folder)){
     601            if (!mkdir($tmp_folder)) {
    591602                return false;
    592603            }
    593604        }
     605
    594606        return true;
    595607    }
     
    602614
    603615        if (!is_dir($tmp_folder)) {
    604             if($this->make_tmp_folder()){
     616            if ($this->make_tmp_folder()) {
    605617                return true;
    606618            } else {
     
    608620            }
    609621        }
    610        
     622
    611623        if ($dh = opendir($tmp_folder)) {
    612             while(($file = readdir($dh)) !== false) {
     624            while (($file = readdir($dh)) !== false) {
    613625                if ($file != '.' && $file != '..') {
    614                     if (is_file($tmp_folder . '/' . $file)){
     626                    if (is_file($tmp_folder . '/' . $file)) {
    615627                        unlink($tmp_folder . '/' . $file);
    616628                    }
     
    619631            closedir($dh);
    620632        }
     633
    621634        return true;
    622635    }
     
    642655            'mysql' => '1.907',
    643656            'wordpress_db' => [
    644                 'time' => '1.606',
    645                 'queries_per_second' => '1245.33',
     657                'time' => '1.290',
     658                'queries_per_second' => '1550.38',
    646659            ],
    647660            'filesystem' => '2.503',
    648661        ];
    649        
     662
    650663        $results['a2hosting-other'] = [
    651664            'name' => 'Fly',
     
    662675            'mysql' => '1.863',
    663676            'wordpress_db' => [
    664                 'time' => '1.673',
    665                 'queries_per_second' => '1195.4',
     677                'time' => '1.232',
     678                'queries_per_second' => '1623.37',
    666679            ],
    667680            'filesystem' => '2.337',
    668681        ];
    669682
    670         if(file_exists('/opt/a2-optimized/wordpress/class.A2_Optimized_Private_Optimizations_v3.php')){
    671             require_once('/opt/a2-optimized/wordpress/class.A2_Optimized_Private_Optimizations_v3.php');
    672             $private_opts = new A2_Optimized_Private_Optimizations();
     683        if (file_exists('/opt/a2-optimized/wordpress/class.A2_Optimized_Private_Optimizations_v3.php')) {
     684            require_once('/opt/a2-optimized/wordpress/class.A2_Optimized_Private_Optimizations_v3.php');
     685            $private_opts = new A2_Optimized_Private_Optimizations();
    673686            $results['a2hosting-other'] = $private_opts->get_baseline_results();
    674         }
     687        }
    675688
    676689        return $results;
    677690    }
    678 
    679691}
  • a2-optimized-wp/trunk/readme.txt

    r2949508 r2954507  
    44Requires at least: 5.1
    55Tested up to: 6.3
    6 Stable tag: 3.0.6.4.1
     6Stable tag: 3.0.6.4.2
    77Requires PHP: 5.6
    88License: GPLv3
Note: See TracChangeset for help on using the changeset viewer.