Plugin Directory

Changeset 3184499


Ignore:
Timestamp:
11/08/2024 02:45:51 PM (17 months ago)
Author:
johndarrel
Message:

Update compatibility with LiteSpeed to customize the caching path as cache/ls

Location:
hide-my-wp/trunk/models
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • hide-my-wp/trunk/models/Compatibility.php

    r3184244 r3184499  
    271271        // Change the paths in the cached css
    272272        if ( HMWP_Classes_Tools::isPluginActive( 'litespeed-cache/litespeed-cache.php' ) ) {
    273             // Set the cache directory for this plugin
     273
     274            //Set the cache directory for this plugin
    274275            $path = $content_dir . 'litespeed/';
     276
     277            //if set by the plugin, them select the defined folder
     278            if( defined('LITESPEED_DATA_FOLDER') && LITESPEED_DATA_FOLDER <> ''){
     279                $path = $content_dir . LITESPEED_DATA_FOLDER . '/';
     280            }
     281
    275282            if ( $wp_filesystem->is_dir( $path ) ) {
    276283                HMWP_Classes_ObjController::getClass( 'HMWP_Models_Cache' )->setCachePath( $path );
  • hide-my-wp/trunk/models/compatibility/LiteSpeed.php

    r3184244 r3184499  
    1010
    1111class HMWP_Models_Compatibility_LiteSpeed extends HMWP_Models_Compatibility_Abstract {
     12
     13    public function __construct() {
     14
     15        parent::__construct();
     16
     17        defined( 'LITESPEED_DATA_FOLDER' ) || define( 'LITESPEED_DATA_FOLDER', 'cache/ls' );
     18    }
    1219
    1320    public function hookAdmin() {
     
    3138        // Only if the litespeed plugin is installed
    3239        if ( HMWP_Classes_Tools::isPluginActive( 'litespeed-cache/litespeed-cache.php' ) ) {
    33             add_action( 'hmwp_mappsettings_saved', array( $this, 'doMapping' ) );
    3440
    3541            if ( ! HMWP_Classes_Tools::isWpengine() ) {
    36                 add_action( 'hmwp_settings_saved', array( $this, 'doMapping' ) );
    3742                add_action( 'hmwp_settings_saved', array( $this, 'doExclude' ) );
    3843            }
     
    5661        add_filter( 'hmwp_priority_buffer', '__return_true' );
    5762        add_filter( 'litespeed_comment', '__return_false' );
    58 
    59     }
    60 
    61     /**
    62      * Adds the URL and text mappings for the wp-rocket plugin, particularly
    63      * mapping specific paths and script branding for litespeed caching.
    64      *
    65      * @return void
    66      * @throws Exception
    67      */
    68     public function doMapping() {
    69 
    70         // Add the URL mapping for wp-rocket plugin
    71         if ( HMWP_Classes_Tools::getDefault( 'hmwp_wp-content_url' ) <> HMWP_Classes_Tools::getOption( 'hmwp_wp-content_url' ) ) {
    72             $hmwp_url_mapping  = json_decode( HMWP_Classes_Tools::getOption( 'hmwp_url_mapping' ), true );
    73             $hmwp_text_mapping = json_decode( HMWP_Classes_Tools::getOption( 'hmwp_text_mapping' ), true );
    74 
    75             // Map the litespeed default cache path
    76             if ( HMWP_Classes_Tools::getDefault( 'hmwp_wp-content_url' ) <> HMWP_Classes_Tools::getOption( 'hmwp_wp-content_url' ) ) {
    77                 if ( empty( $hmwp_url_mapping['from'] ) || ! in_array( '/' . HMWP_Classes_Tools::getOption( 'hmwp_wp-content_url' ) . '/litespeed/', $hmwp_url_mapping['from'] ) ) {
    78                     $hmwp_url_mapping['from'][] = '/' . HMWP_Classes_Tools::getOption( 'hmwp_wp-content_url' ) . '/litespeed/';
    79                     $hmwp_url_mapping['to'][]   = '/' . HMWP_Classes_Tools::getOption( 'hmwp_wp-content_url' ) . '/mycache/';
    80                 }
    81             }
    82 
    83             // Map the litespeed script branding
    84             if ( empty( $hmwp_text_mapping['from'] ) || ! in_array( 'litespeed', $hmwp_text_mapping['from'] ) ) {
    85                 $hmwp_text_mapping['from'][] = 'litespeed';
    86                 $hmwp_text_mapping['to'][]   = 'text';
    87             }
    88 
    89             //Save Text Mapping and URL Mapping
    90             HMWP_Classes_ObjController::getClass( 'HMWP_Models_Settings' )->saveURLMapping( $hmwp_url_mapping['from'], $hmwp_url_mapping['to'] );
    91             HMWP_Classes_ObjController::getClass( 'HMWP_Models_Settings' )->saveTextMapping( $hmwp_text_mapping['from'], $hmwp_text_mapping['to'] );
    92         }
    9363
    9464    }
Note: See TracChangeset for help on using the changeset viewer.