Plugin Directory

Changeset 3680120


Ignore:
Timestamp:
09/03/2026 05:08:29 PM (3 months ago)
Author:
johndarrel
Message:
  • Fix - LiteSpeed: the QUIC.cloud address list is refreshed on its own and no longer kept forever, so QUIC.cloud keeps working as their addresses change
  • Fix - LiteSpeed: the QUIC.cloud addresses are loaded even when the plugin settings have not been saved since LiteSpeed was installed
  • Fix - Defender Security: the free edition of the plugin is now recognized, not only the Pro edition
  • Fix - Ghost Doctor no longer reports the CSS and JS files as not loading when Text Mapping in CSS and JS files is on and those files are served by WordPress on purpose
  • Fix - Ghost Doctor now checks the REST API path the way WordPress answers it, instead of reporting a working REST API as missing
  • Fix - Changing the REST API path takes effect on save, without having to open Settings > Permalinks and save again
Location:
hide-my-wp/tags/7.0.10
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • hide-my-wp/tags/7.0.10/controllers/SecurityCheck.php

    r3651560 r3680120  
    942942                // no working rewrite is still reported.
    943943                if ( ! HMWP_Classes_Tools::isPHPPermalink() ) {
    944                         $url         = home_url() . '/' . HMWP_Classes_Tools::getOption( 'hmwp_wp-json' );
     944                        // The renamed REST path only resolves with the trailing slash
     945                        $url         = home_url() . '/' . trailingslashit( HMWP_Classes_Tools::getOption( 'hmwp_wp-json' ) );
    945946                        $rest_closed = (bool) HMWP_Classes_Tools::getOption( 'hmwp_disable_rest_api' );
    946947                } else {
    … …  
    10651066                        }
    10661067
     1068                        // When the text mapping in CSS and JS files is on, the server rules send the
     1069                        // CSS and JS to WordPress on purpose, so those files are expected to be
     1070                        // served by the plugin and must not be probed with the fallback disabled
     1071                        $dynamicfiles = ( ( defined( 'HMW_DYNAMIC_FILES' ) && HMW_DYNAMIC_FILES ) ||
     1072                                          ( HMWP_Classes_Tools::getOption( 'hmwp_mapping_text_show' ) && HMWP_Classes_Tools::getOption( 'hmwp_mapping_file' ) ) );
     1073
    10671074                        foreach ( $assets as $asset ) {
     1075
     1076                                $extension = strtolower( (string) pathinfo( (string) wp_parse_url( $asset, PHP_URL_PATH ), PATHINFO_EXTENSION ) );
     1077
    10681078                                // Bypass the WordPress fallback handler (showFile) so only the server config
    10691079                                // rules serve the file. Otherwise a broken rewrite is masked by a 200 response.
    … …  
    10811091                                $code   = is_wp_error( $response ) ? 0 : (int) wp_remote_retrieve_response_code( $response );
    10821092                                $failed = ( ! is_wp_error( $response ) && in_array( $code, array( 404, 302, 301 ) ) );
     1093
     1094                                // The CSS and JS are sent to WordPress on purpose when the text mapping in
     1095                                // files is on, so ask for the file the way a visitor does before calling it
     1096                                // broken. An asset that answers to a normal request is not broken.
     1097                                if ( $failed && $dynamicfiles && in_array( $extension, array( 'js', 'css', 'scss' ), true ) ) {
     1098
     1099                                        $plain = ( is_ssl() ? str_replace( 'http://', 'https://', $asset ) : $asset );
     1100
     1101                                        $response = HMWP_Classes_Tools::hmwp_localcall( $plain, array(
     1102                                                'redirection' => 0,
     1103                                                'cookies'     => false
     1104                                        ) );
     1105
     1106                                        $code   = is_wp_error( $response ) ? 0 : (int) wp_remote_retrieve_response_code( $response );
     1107                                        $failed = ( ! is_wp_error( $response ) && in_array( $code, array( 404, 302, 301 ) ) );
     1108                                }
    10831109
    10841110                                $checks[] = array( 'role' => 'asset', 'url' => $asset, 'code' => $code, 'ok' => ! $failed );
  • hide-my-wp/tags/7.0.10/models/Compatibility.php

    r3590186 r3680120  
    6363                        'wp-user-manager/wp-user-manager.php'                                           => 'HMWP_Models_Compatibility_Wpum',
    6464                        'wp-defender/wp-defender.php'                                                   => 'HMWP_Models_Compatibility_WpDefender',
     65                        'defender-security/wp-defender.php'                                                   => 'HMWP_Models_Compatibility_WpDefender',
    6566                        'cmp-coming-soon-maintenance/niteo-cmp.php'                                     => 'HMWP_Models_Compatibility_Cmp',
    6667                        'display-admin-page-on-frontend-premium/index.php'                              => 'HMWP_Models_Compatibility_WPFrontendAdmin',
  • hide-my-wp/tags/7.0.10/models/Files.php

    r3678426 r3680120  
    1919        protected $_site_url = null;
    2020        protected $_site_hosts = array();
     21        protected $_fingerprint = null;
     22        protected $_cachedir = null;
    2123
    2224        public function __construct() {
    … …  
    327329
    328330                return apply_filters( 'hmwp_files_response_headers', $headers, $response );
     331        }
     332
     333        /**
     334         * Fingerprint of everything that changes the mapped file content
     335         *
     336         * @return string
     337         * @throws Exception
     338         */
     339        public function getMappingFingerprint() {
     340
     341                if ( ! isset( $this->_fingerprint ) ) {
     342
     343                        /** @var HMWP_Models_Rewrite $rewriteModel */
     344                        $rewriteModel = HMWP_Classes_ObjController::getClass( 'HMWP_Models_Rewrite' );
     345
     346                        // Build the map the same way find_replace_url does it
     347                        if ( empty( $rewriteModel->_replace ) ) {
     348                                $rewriteModel->buildRedirect();
     349                                $rewriteModel->prepareFindReplace();
     350                        }
     351
     352                        // The map holds the CDN and the third party changes, so it covers more than the plugin options
     353                        $this->_fingerprint = md5( wp_json_encode( array(
     354                                $rewriteModel->_replace,
     355                                HMWP_Classes_Tools::getOption( 'hmwp_text_mapping' ),
     356                                HMWP_Classes_Tools::getOption( 'hmwp_mapping_classes' ),
     357                                HMWP_Classes_Tools::getOption( 'hmwp_mapping_text_show' ),
     358                                HMWP_Classes_Tools::getOption( 'hmwp_mapping_file' ),
     359                                HMWP_Classes_Tools::isLoggedInUser(),
     360                                ( is_multisite() ? get_current_blog_id() : 0 ),
     361                        ) ) );
     362                }
     363
     364                return $this->_fingerprint;
     365        }
     366
     367        /**
     368         * Build the cache validator for a file
     369         *
     370         * @param  string  $path  The file path on the server
     371         * @param  bool  $mapped  True when the content is changed before it's sent
     372         *
     373         * @return array The etag and the last modified time
     374         * @throws Exception
     375         */
     376        public function getFileValidator( $path, $mapped = false ) {
     377
     378                // Initialize WordPress Filesystem
     379                $wp_filesystem = HMWP_Classes_ObjController::initFilesystem();
     380
     381                $mtime = (int) $wp_filesystem->mtime( $path );
     382                $size  = (int) $wp_filesystem->size( $path );
     383
     384                // The mapped content changes with the settings, add them in the validator
     385                $fingerprint = ( $mapped ? $this->getMappingFingerprint() : '' );
     386
     387                return array(
     388                        'etag'  => md5( $path . '|' . $mtime . '|' . $size . '|' . $fingerprint ),
     389                        'mtime' => $mtime,
     390                        'size'  => $size,
     391                );
     392        }
     393
     394        /**
     395         * Check if the browser already has the current version of the file
     396         *
     397         * @param  string  $etag  The current etag
     398         * @param  int  $mtime  The last modified time
     399         *
     400         * @return bool
     401         */
     402        public function isNotModified( $etag, $mtime ) {
     403
     404                // The etag has priority over the modified time
     405                if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
     406
     407                        $match = trim( wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ) ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
     408
     409                        if ( $match <> '' ) {
     410                                // The browser can send more etags and the W/ prefix for the weak validators
     411                                foreach ( explode( ',', $match ) as $value ) {
     412                                        $value = trim( str_replace( array( 'W/', '"' ), '', $value ) );
     413                                        if ( $value <> '' && $value === $etag ) {
     414                                                return true;
     415                                        }
     416                                }
     417
     418                                return false;
     419                        }
     420                }
     421
     422                if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) && $mtime > 0 ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
     423
     424                        $since = strtotime( trim( wp_unslash( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
     425
     426                        if ( $since !== false && $mtime <= $since ) {
     427                                return true;
     428                        }
     429                }
     430
     431                return false;
     432        }
     433
     434        /**
     435         * Get the compression accepted by the browser
     436         *
     437         * @return string br, gzip or empty when the content is sent as it is
     438         */
     439        public function getAcceptedEncoding() {
     440
     441                // Don't compress twice when the server already does it
     442                if ( ini_get( 'zlib.output_compression' ) ) {
     443                        return '';
     444                }
     445
     446                if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
     447                        return '';
     448                }
     449
     450                $accepted = array();
     451
     452                foreach ( explode( ',', strtolower( wp_unslash( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) ) as $value ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
     453
     454                        $parts  = explode( ';', $value );
     455                        $name   = trim( $parts[0] );
     456                        $weight = 1;
     457
     458                        // Skip the encodings the browser refuses with q=0
     459                        if ( isset( $parts[1] ) && strpos( $parts[1], 'q=' ) !== false ) {
     460                                $weight = (float) str_replace( 'q=', '', trim( $parts[1] ) );
     461                        }
     462
     463                        if ( $name <> '' && $weight > 0 ) {
     464                                $accepted[] = $name;
     465                        }
     466                }
     467
     468                if ( in_array( 'br', $accepted, true ) && function_exists( 'brotli_compress' ) ) {
     469                        return 'br';
     470                }
     471
     472                if ( in_array( 'gzip', $accepted, true ) && function_exists( 'gzencode' ) ) {
     473                        return 'gzip';
     474                }
     475
     476                return '';
     477        }
     478
     479        /**
     480         * Get the directory where the changed CSS and JS files are kept
     481         *
     482         * It's never under wp-content/cache, that directory is scanned and rewritten
     483         * by checkCacheFiles when no known cache plugin is installed.
     484         *
     485         * @return string The cache directory with trailing slash, empty when it can't be used
     486         */
     487        public function getCacheDir() {
     488
     489                if ( isset( $this->_cachedir ) ) {
     490                        return $this->_cachedir;
     491                }
     492
     493                $this->_cachedir = '';
     494
     495                $uploads = wp_upload_dir( null, false );
     496
     497                if ( ! empty( $uploads['error'] ) || empty( $uploads['basedir'] ) ) {
     498                        return $this->_cachedir;
     499                }
     500
     501                $dir = trailingslashit( $uploads['basedir'] ) . 'wp-ghost-cache/';
     502                $dir = apply_filters( 'hmwp_files_cache_dir', $dir );
     503
     504                // Initialize WordPress Filesystem
     505                $wp_filesystem = HMWP_Classes_ObjController::initFilesystem();
     506
     507                if ( ! $wp_filesystem->is_dir( $dir ) ) {
     508
     509                        if ( ! $wp_filesystem->mkdir( $dir, HMW_DIR_PERMISSION ) ) {
     510                                return $this->_cachedir;
     511                        }
     512
     513                        // Keep the directory private
     514                        $wp_filesystem->put_contents( $dir . 'index.php', '<?php // Silence is golden', HMW_FILE_PERMISSION );
     515                        $deny = "<IfModule mod_authz_core.c>" . PHP_EOL . "Require all denied" . PHP_EOL . "</IfModule>" . PHP_EOL;
     516                        $deny .= "<IfModule !mod_authz_core.c>" . PHP_EOL . "Order Allow,Deny" . PHP_EOL . "Deny from all" . PHP_EOL . "</IfModule>" . PHP_EOL;
     517
     518                        $wp_filesystem->put_contents( $dir . '.htaccess', $deny, HMW_FILE_PERMISSION );
     519                }
     520
     521                if ( ! $wp_filesystem->is_writable( $dir ) ) {
     522                        return $this->_cachedir;
     523                }
     524
     525                $this->_cachedir = $dir;
     526
     527                return $this->_cachedir;
     528        }
     529
     530        /**
     531         * Check if the changed content of a file can be kept on disk
     532         *
     533         * @return bool
     534         */
     535        public function isCacheable() {
     536
     537                // The content is not changed for logged in users, caching it would
     538                // send the original paths to the visitors
     539                if ( HMWP_Classes_Tools::isLoggedInUser() ) {
     540                        return false;
     541                }
     542
     543                // A random text mapping is generated on every request by design
     544                $mapping = json_decode( HMWP_Classes_Tools::getOption( 'hmwp_text_mapping' ), true );
     545
     546                if ( isset( $mapping['to'] ) && is_array( $mapping['to'] ) ) {
     547                        foreach ( $mapping['to'] as $value ) {
     548                                if ( strpos( (string) $value, '{rand}' ) !== false ) {
     549                                        return false;
     550                                }
     551                        }
     552                }
     553
     554                return (bool) apply_filters( 'hmwp_files_cache', true );
     555        }
     556
     557        /**
     558         * Get the file which holds the changed content
     559         *
     560         * @param  string  $etag  The validator of the original file
     561         * @param  string  $encoding  The compression used for the content
     562         *
     563         * @return string The path of the cache file, empty when it can't be used
     564         */
     565        public function getCacheFile( $etag, $encoding ) {
     566
     567                if ( ! $dir = $this->getCacheDir() ) {
     568                        return '';
     569                }
     570
     571                // The extension is never css or js, so the cache rewriting never picks these files up
     572                return $dir . md5( $etag . '|' . $encoding ) . '.cache';
     573        }
     574
     575        /**
     576         * Save the changed content so it's not rebuilt on every request
     577         *
     578         * @param  string  $file  The cache file path
     579         * @param  string  $content  The content to save
     580         *
     581         * @return void
     582         */
     583        public function saveCacheFile( $file, $content ) {
     584
     585                // Initialize WordPress Filesystem
     586                $wp_filesystem = HMWP_Classes_ObjController::initFilesystem();
     587
     588                // Write in a temporary file first so a visitor never reads half a file
     589                $temp = $file . '.' . wp_rand( 100000, 999999 ) . '.tmp';
     590
     591                if ( $wp_filesystem->put_contents( $temp, $content, HMW_FILE_PERMISSION ) ) {
     592                        if ( ! @rename( $temp, $file ) ) { //phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
     593                                $wp_filesystem->delete( $temp );
     594                        }
     595                }
     596
     597                $this->cleanCacheDir();
     598        }
     599
     600        /**
     601         * Remove the cache files left behind when a file or a setting changed
     602         *
     603         * @return void
     604         */
     605        public function cleanCacheDir() {
     606
     607                if ( ! $dir = $this->getCacheDir() ) {
     608                        return;
     609                }
     610
     611                // Initialize WordPress Filesystem
     612                $wp_filesystem = HMWP_Classes_ObjController::initFilesystem();
     613
     614                $marker = $dir . 'last-clean';
     615                $lifetime = (int) apply_filters( 'hmwp_files_cache_lifetime', WEEK_IN_SECONDS );
     616
     617                // Only look through the directory once a day
     618                if ( $wp_filesystem->exists( $marker ) && ( time() - (int) $wp_filesystem->mtime( $marker ) ) < DAY_IN_SECONDS ) {
     619                        return;
     620                }
     621
     622                $wp_filesystem->put_contents( $marker, (string) time(), HMW_FILE_PERMISSION );
     623
     624                if ( ! function_exists( 'glob' ) ) {
     625                        return;
     626                }
     627
     628                if ( $files = glob( $dir . '*.cache' ) ) {
     629                        foreach ( $files as $file ) {
     630                                if ( ( time() - (int) $wp_filesystem->mtime( $file ) ) > $lifetime ) {
     631                                        $wp_filesystem->delete( $file );
     632                                }
     633                        }
     634                }
     635
     636                // Clean up the temporary files left by an interrupted write
     637                if ( $files = glob( $dir . '*.tmp' ) ) {
     638                        foreach ( $files as $file ) {
     639                                if ( ( time() - (int) $wp_filesystem->mtime( $file ) ) > HOUR_IN_SECONDS ) {
     640                                        $wp_filesystem->delete( $file );
     641                                }
     642                        }
     643                }
     644        }
     645
     646        /**
     647         * Close all the output buffers before sending a file
     648         *
     649         * @return void
     650         */
     651        public function closeBuffers() {
     652
     653                while ( ob_get_level() ) {
     654                        ob_end_clean();
     655                }
    329656        }
    330657
    … …  
    594921                                        //////////////////////////////////////////////////////////////////////////
    595922
    596                                         ob_clean(); //clear the buffer
    597                                         $content = $wp_filesystem->get_contents( $new_path );
    598                                         $etag    = md5_file( $new_path );
    599 
    600                                         if ( function_exists( 'http_response_code' ) ) {
    601                                                 http_response_code( 200 );
    602                                         }
    603 
    604                                         header( "HTTP/1.1 200 OK" );
     923                                        // Only the CSS, JS and SCSS content is changed before it's sent
     924                                        $ismapped = ( strpos( $new_url, '.js' ) || strpos( $new_url, '.css' ) || strpos( $new_url, '.scss' ) );
     925
     926                                        // Build the validator before the file is read
     927                                        $validator = $this->getFileValidator( $new_path, $ismapped );
     928
    605929                                        header( "Cache-Control: max-age=2592000, must-revalidate" );
    606930                                        header( "Expires: " . gmdate( 'r', strtotime( "+1 month" ) ) );
    607931                                        header( "Vary: Accept-Encoding" );
    608932                                        header( "Pragma: public" );
    609                                         header( "Etag: \"{$etag}\"" );
     933                                        header( 'Etag: "' . $validator['etag'] . '"' );
     934
     935                                        if ( $validator['mtime'] > 0 ) {
     936                                                header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', $validator['mtime'] ) . ' GMT' );
     937                                        }
     938
     939                                        // Answer the conditional request without reading the file
     940                                        if ( $this->isNotModified( $validator['etag'], $validator['mtime'] ) ) {
     941
     942                                                $this->closeBuffers();
     943
     944                                                if ( function_exists( 'http_response_code' ) ) {
     945                                                        http_response_code( 304 );
     946                                                }
     947
     948                                                header( "HTTP/1.1 304 Not Modified" );
     949                                                exit();
     950                                        }
     951
     952                                        if ( function_exists( 'http_response_code' ) ) {
     953                                                http_response_code( 200 );
     954                                        }
     955
     956                                        header( "HTTP/1.1 200 OK" );
    610957
    611958                                        if ( $mime ) {
    … …  
    614961
    615962                                        //////////////////////////////////////////////////////////////////////////
     963                                        // The images, fonts and media need no change, send them without loading them in memory
     964                                        if ( ! $ismapped ) {
     965
     966                                                $this->closeBuffers();
     967
     968                                                if ( $validator['size'] > 0 ) {
     969                                                        header( 'Content-Length: ' . $validator['size'] );
     970                                                }
     971
     972                                                if ( readfile( $new_path ) === false ) {
     973                                                        echo $wp_filesystem->get_contents( $new_path ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     974                                                }
     975
     976                                                exit();
     977                                        }
     978
     979                                        //////////////////////////////////////////////////////////////////////////
    616980                                        // If CSS, JS or SCSS
    617                                         if ( strpos( $new_url, '.js' ) || strpos( $new_url, '.css' ) || strpos( $new_url, '.scss' ) ) {
    618 
    619                                                 // URL Mapping for all css and js files
    620                                                 $content = HMWP_Classes_ObjController::getClass( 'HMWP_Models_Rewrite' )->find_replace_url( $content );
    621                                                 // Text Mapping for all css and js files
    622                                                 $content = HMWP_Classes_ObjController::getClass( 'HMWP_Models_Rewrite' )->replaceTextMapping( $content, true );
    623 
    624                                                 // Cache the CSS and JS files if no cache plugin is installed
    625                                                 if ( function_exists( 'brotli_compress' ) ) {
    626                                                         // Brotli the CSS, JS
    627                                                         header( "Content-Encoding: br" );
     981                                        $encoding = $this->getAcceptedEncoding();
     982
     983                                        if ( $encoding ) {
     984                                                header( 'Content-Encoding: ' . $encoding );
     985                                        }
     986
     987                                        // The changed content is the same for every visitor, build it once
     988                                        $cachefile = ( $this->isCacheable() ? $this->getCacheFile( $validator['etag'], $encoding ) : '' );
     989
     990                                        if ( $cachefile && $wp_filesystem->exists( $cachefile ) ) {
     991
     992                                                $this->closeBuffers();
     993
     994                                                if ( $cachesize = (int) $wp_filesystem->size( $cachefile ) ) {
     995                                                        header( 'Content-Length: ' . $cachesize );
     996                                                }
     997
     998                                                if ( readfile( $cachefile ) !== false ) {
     999                                                        exit();
     1000                                                }
     1001                                        }
     1002
     1003                                        ob_clean(); //clear the buffer
     1004                                        $content = $wp_filesystem->get_contents( $new_path );
     1005
     1006                                        // URL Mapping for all css and js files
     1007                                        $content = HMWP_Classes_ObjController::getClass( 'HMWP_Models_Rewrite' )->find_replace_url( $content );
     1008                                        // Text Mapping for all css and js files
     1009                                        $content = HMWP_Classes_ObjController::getClass( 'HMWP_Models_Rewrite' )->replaceTextMapping( $content, true );
     1010
     1011                                        // Compress the CSS and JS only with what the browser accepts
     1012                                        switch ( $encoding ) {
     1013                                                case 'br':
    6281014                                                        $content = brotli_compress( $content, 1 );
    629                                                 } elseif ( function_exists( 'gzcompress' ) ) {
    630                                                         // deflate the  CSS, JS
    631                                                         header( "Content-Encoding: deflate" );
    632                                                         $content = gzcompress( $content );
    633                                                 } elseif ( function_exists( 'gzencode' ) ) {
    634                                                         // Gzip the  CSS, JS
    635                                                         header( "Content-Encoding: gzip" );
     1015                                                        break;
     1016                                                case 'gzip':
    6361017                                                        $content = gzencode( $content );
    637                                                 }
    638 
    639                                                 // Show the file html content
    640                                                 header( 'Content-Length: ' . strlen( $content ) );
    641                                         }
     1018                                                        break;
     1019                                        }
     1020
     1021                                        // Keep the built content for the next request
     1022                                        if ( $cachefile ) {
     1023                                                $this->saveCacheFile( $cachefile, $content );
     1024                                        }
     1025
     1026                                        // Show the file html content
     1027                                        header( 'Content-Length: ' . strlen( $content ) );
    6421028
    6431029                                        echo $content; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  • hide-my-wp/tags/7.0.10/models/Rewrite.php

    r3609415 r3680120  
    999999        public function flushChanges() {
    10001000
     1001                // Wait for all the plugins to register their rules, otherwise the flush drops them
    10011002                if ( ! did_action( 'wp_loaded' ) ) {
    10021003                        add_action( 'wp_loaded', array( $this, 'flushChanges' ) );
     1004
     1005                        return;
    10031006                }
    10041007
    … …  
    27112714
    27122715        /**
     2716         * Build the REST API rewrite rules again after the REST API path changed
     2717         *
     2718         * WordPress keeps these rules in the database, so changing the path is not
     2719         * enough, the rules have to be generated again with the new prefix.
     2720         *
     2721         * @return void
     2722         */
     2723        public function flushRestRewrites() {
     2724
     2725                // Wait for all the plugins to register their rules, otherwise the flush drops them
     2726                if ( ! did_action( 'wp_loaded' ) ) {
     2727                        add_action( 'wp_loaded', array( $this, 'flushRestRewrites' ) );
     2728
     2729                        return;
     2730                }
     2731
     2732                // Make sure the custom REST API path is used while the rules are built
     2733                add_filter( 'rest_url_prefix', array( $this, 'replace_rest_api' ) );
     2734
     2735                // Register the REST API rules with the new prefix
     2736                rest_api_register_rewrites();
     2737
     2738                // Soft flush, the config file rules are handled by the plugin
     2739                flush_rewrite_rules( false );
     2740
     2741                do_action( 'hmwp_flushed_rest_rewrites' );
     2742        }
     2743
     2744        /**
    27132745         * Replace the wp-json URL is changed
    27142746         *
  • hide-my-wp/tags/7.0.10/models/Settings.php

    r3527331 r3680120  
    612612                }
    613613
     614                // The REST API rules are stored by WordPress, build them again when the path
     615                // changed, also when the config file is not writable and flushChanges was skipped
     616                if ( HMWP_Classes_Tools::getDefault( 'hmwp_wp-json' ) <> HMWP_Classes_Tools::getOption( 'hmwp_wp-json' ) ) {
     617                        HMWP_Classes_ObjController::getClass( 'HMWP_Models_Rewrite' )->flushRestRewrites();
     618                }
     619
    614620                //If there are no errors
    615621                if ( ! HMWP_Classes_Error::isError() ) {
  • hide-my-wp/tags/7.0.10/models/compatibility/LiteSpeed.php

    r3495262 r3680120  
    5050
    5151                // Whitelist Litespeed quic cloud Ips after settings save
    52                 add_action( 'hmwp_settings_saved', function (){
    53                         $quic_ips = HMWP_Classes_Tools::hmwp_remote_get( 'https://www.quic.cloud/ips-all?json' );
    54                         set_transient( 'hmwp_lispeed_ips', $quic_ips );
    55                 } );
     52                add_action( 'hmwp_settings_saved', array( $this, 'loadQuicCloudIPs' ) );
     53
     54                $quic_ips = get_transient( 'hmwp_lispeed_ips' );
     55
     56                // Quic Cloud changes the IPs in time, load them again when the list expired
     57                // Only in admin or cron, never on a visitor request
     58                if ( $quic_ips === false && ( is_admin() || HMWP_Classes_Tools::isCron() ) && ! get_transient( 'hmwp_lispeed_ips_lock' ) ) {
     59                        $quic_ips = $this->loadQuicCloudIPs();
     60                }
    5661
    5762                // Add Litespeed IPs in whitelist
    58                 if( $quic_ips = get_transient('hmwp_lispeed_ips') ){
     63                if( $quic_ips ){
    5964                        add_filter( 'hmwp_whitelisted_ips', function ( $ips ) use ( $quic_ips ) {
    6065
    … …  
    8590
    8691        /**
     92         * Load the Quic Cloud IPs and keep them for a week
     93         *
     94         * @return string|false The IP list as received from Quic Cloud
     95         */
     96        public function loadQuicCloudIPs() {
     97
     98                // Don't call Quic Cloud again for an hour if the list can't be loaded
     99                set_transient( 'hmwp_lispeed_ips_lock', 1, HOUR_IN_SECONDS );
     100
     101                $quic_ips = HMWP_Classes_Tools::hmwp_remote_get( 'https://www.quic.cloud/ips-all?json' );
     102
     103                if ( ! is_string( $quic_ips ) || $quic_ips == '' || ! json_decode( $quic_ips, true ) ) {
     104                        return false;
     105                }
     106
     107                set_transient( 'hmwp_lispeed_ips', $quic_ips, WEEK_IN_SECONDS );
     108
     109                return $quic_ips;
     110        }
     111
     112        /**
    87113         * Check and handle LiteSpeed media optimization scan.
    88114         *
  • hide-my-wp/tags/7.0.10/models/compatibility/Woocommerce.php

    r3495262 r3680120  
    6969                     $uri &&
    7070                     (
    71                              strpos( $uri, '/wc-api/v' ) !== false ||
    72                              preg_match( '/\/(paypal|stripe|square|authorize_net|braintree)/', $uri )
     71                             HMWP_Classes_Tools::getIsset( 'wc-api' ) ||
     72                             HMWP_Classes_Tools::getIsset( 'wc-ajax' ) ||
     73                             preg_match( '#/(' . preg_quote( HMWP_Classes_Tools::getOption( 'hmwp_wp-json' ), '#' ) . '|' . preg_quote( HMWP_Classes_Tools::getDefault( 'hmwp_wp-json' ), '#' ) . ')/[^/]*(paypal|stripe|square|authorize[_-]?net|braintree)#i', $uri )
    7374                     )
    7475             )
  • hide-my-wp/tags/7.0.10/readme.txt

    r3678426 r3680120  
    217217= 7.0.10 (2 September 2026) =
    218218* Update - Security update: hardening for the way the plugin resolves and handles the current request
     219* Fix - CSS and JS are compressed only with what the browser actually accepts, instead of always answering compressed
     220* Fix - Compressed responses now use gzip, which every browser and CDN reads the same way
    219221* Fix - Static files and the REST API path are now handled correctly when your site is reached on an alias domain
    220222* Fix - REST API responses handled by the plugin no longer carry compression headers that do not match the returned content
     223* Fix - LiteSpeed: the QUIC.cloud address list is refreshed on its own and no longer kept forever, so QUIC.cloud keeps working as their addresses change
     224* Fix - LiteSpeed: the QUIC.cloud addresses are loaded even when the plugin settings have not been saved since LiteSpeed was installed
     225* Fix - Defender Security: the free edition of the plugin is now recognized, not only the Pro edition
     226* Fix - Ghost Doctor no longer reports the CSS and JS files as not loading when Text Mapping in CSS and JS files is on and those files are served by WordPress on purpose
     227* Fix - Ghost Doctor now checks the REST API path the way WordPress answers it, instead of reporting a working REST API as missing
     228* Fix - Changing the REST API path takes effect on save, without having to open Settings > Permalinks and save again
    221229* Fix - No longer stops with a fatal error on servers where the getallheaders() function is missing
    222 * New - New hmwp_files_allowed_hosts, hmwp_files_request_headers, hmwp_files_response_headers and hmwp_files_skip_headers filters for developers
     230* New - New hmwp_files_allowed_hosts, hmwp_files_request_headers, hmwp_files_response_headers, hmwp_files_skip_headers, hmwp_files_cache, hmwp_files_cache_dir and hmwp_files_cache_lifetime filters for developers
    223231
    224232= 7.0.09 (17 August 2026) =
Note: See TracChangeset for help on using the changeset viewer.