Skip to content

Commit

Permalink
v4.4.3-rc2: * **Conf** Dropped .htaccess Path Settings options. (WP…
Browse files Browse the repository at this point in the history
…) * **API** Added `LITESPEED_CFG_HTACCESS` PHP Constant to specify .htaccess path.
  • Loading branch information
hi-hai committed Oct 7, 2021
1 parent 5d037a1 commit 23f4041
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 136 deletions.
6 changes: 0 additions & 6 deletions data/const.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,6 @@ crawler-cookies = ''
;; -------------- Misc ----------------- ;;
;; -------------------------------------------------- ;;

; O_MISC_HTACCESS_FRONT
misc-htaccess_front = ''

; O_MISC_HTACCESS_BACK
misc-htaccess_back = ''

; O_MISC_HEARTBEAT_FRONT
misc-heartbeat_front = false

Expand Down
4 changes: 2 additions & 2 deletions litespeed-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: LiteSpeed Cache
* Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
* Description: High-performance page caching and site optimization from LiteSpeed
* Version: 4.4.3-rc1
* Version: 4.4.3-rc2
* Author: LiteSpeed Technologies
* Author URI: https://www.litespeedtech.com
* License: GPLv3
Expand Down Expand Up @@ -33,7 +33,7 @@
return;
}

! defined( 'LSCWP_V' ) && define( 'LSCWP_V', '4.4.3-rc1' );
! defined( 'LSCWP_V' ) && define( 'LSCWP_V', '4.4.3-rc2' );

! defined( 'LSCWP_CONTENT_DIR' ) && define( 'LSCWP_CONTENT_DIR', WP_CONTENT_DIR ) ;
! defined( 'LSCWP_DIR' ) && define( 'LSCWP_DIR', __DIR__ . '/' ) ;// Full absolute path '/var/www/html/***/wp-content/plugins/litespeed-cache/' or MU
Expand Down
20 changes: 11 additions & 9 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,20 @@ The vast majority of plugins and themes are compatible with LiteSpeed Cache. The
== Changelog ==

= 4.4.3 - Oct 13 2021 =
* 🐞**Media** Fixed an issue that WebP is wrongly served on older safari under Guest Mode. (hash73)
* **Purge** Disabled `Purge Delay` in optimization process by default.
* 🐞**Media** Fixed an issue where WebP is served erroneously under Guest Mode on older versions of Safari. (hash73)
* **Purge** Disabled `Purge Delay` in the optimization process by default.
* **Conf** Dropped `.htaccess Path Settings` options. (WP)
* **Conf** Dropped `CSS HTTP/2 Push`/`JS HTTP/2 Push` options. (Kevin)
* **Conf** Default `Guest Optimization` to OFF.
* **Conf** Default `CCSS Per URL` to OFF to avoid consuming more quota by default after upgrade to v4. (n111)
* **Object** Fixed Object Cache may result in warning in upgrade process when having GM ON.
* ☁️**Cloud** Fixed a potential PHP notice when not using a service yet when inquiring the quota usage.
* **Conf** Set `Guest Optimization` default to OFF.
* **Conf** Set `CCSS Per URL` default to OFF to avoid consuming more quota than intended after upgrade to v4. (n111)
* **Object** Fixed an issue with Object Cache warnings during upgrade, when Guest Mode is enabled.
* ☁️**Cloud** Fixed an issue with PHP notices when inquiring about quota usage for a service not currently in use.
* **GUI** Added GO detail warning. (n111)
* **GUI** Moved quota wil be still in use warning from GM to GO section.
* **GUI** Moved "quota wil be still in use" warning from Guest Mode to Guest Optimization section.
* **API** Added `LITESPEED_CFG_HTACCESS` PHP Constant to specify .htaccess path.
* **API** Added `litespeed_qs_forbidden` hook to bypass `?LSCWP_CTRL=` query string. (minhduc)
* **API** Added `litespeed_delay_purge` hook to make the following Purge header to be delayed to next request.
* **API** Added `litespeed_wpconfig_readonly` hook to disable wp-config.php file `WP_CACHE` const update. (#633545)
* **API** Added `litespeed_delay_purge` hook to delay the following Purge header until the next request.
* **API** Added `litespeed_wpconfig_readonly` hook to disable `WP_CACHE` constant update based on the wp-config.php file. (#633545)

= 4.4.2 - Sep 23 2021 =
* **Purge** In order to clear pages containing 404 CSS/JS, the purge header will always be sent even in cases where purge must be delayed.
Expand Down
6 changes: 0 additions & 6 deletions src/admin.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ public function wp_update_attachment_metadata( $data, $post_id ) {
private function _proceed_admin_action() {
// handle actions
switch ( Router::get_action() ) {

// Save htaccess
case Router::ACTION_SAVE_HTACCESS:
$this->cls( 'Htaccess' )->htaccess_editor_save();
break;

case Router::ACTION_SAVE_SETTINGS:
$this->cls( 'Admin_Settings' )->save( $_POST );
break;
Expand Down
7 changes: 0 additions & 7 deletions src/base.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ class Base extends Root {
## -------------------------------------------------- ##
## -------------- Misc ----------------- ##
## -------------------------------------------------- ##
const O_MISC_HTACCESS_FRONT = 'misc-htaccess_front';
const O_MISC_HTACCESS_BACK = 'misc-htaccess_back';
const O_MISC_HEARTBEAT_FRONT = 'misc-heartbeat_front';
const O_MISC_HEARTBEAT_FRONT_TTL = 'misc-heartbeat_front_ttl';
const O_MISC_HEARTBEAT_BACK = 'misc-heartbeat_back';
Expand Down Expand Up @@ -507,8 +505,6 @@ class Base extends Root {
self::O_CRAWLER_COOKIES => array(),

// Misc
self::O_MISC_HTACCESS_FRONT => '',
self::O_MISC_HTACCESS_BACK => '',
self::O_MISC_HEARTBEAT_FRONT => false,
self::O_MISC_HEARTBEAT_FRONT_TTL => 0,
self::O_MISC_HEARTBEAT_BACK => false,
Expand Down Expand Up @@ -578,9 +574,6 @@ class Base extends Root {

self::O_IMG_OPTM_WEBP_REPLACE => false,

self::O_MISC_HTACCESS_FRONT => '',
self::O_MISC_HTACCESS_BACK => '',

);

// NOTE: all the val of following items will be int while not bool
Expand Down
56 changes: 2 additions & 54 deletions src/htaccess.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
defined( 'WPINC' ) || exit;

class Htaccess extends Root {
const EDITOR_TEXTAREA_NAME = 'lscwp_ht_editor';

private $frontend_htaccess = null;
private $_default_frontend_htaccess = null;
private $backend_htaccess = null;
Expand Down Expand Up @@ -62,11 +60,11 @@ public function __construct() {
$this->_default_frontend_htaccess = $this->frontend_htaccess;
$this->_default_backend_htaccess = $this->backend_htaccess;

$frontend_htaccess = $this->conf( Base::O_MISC_HTACCESS_FRONT );
$frontend_htaccess = defined( 'LITESPEED_CFG_HTACCESS' ) ? LITESPEED_CFG_HTACCESS : false;
if ( $frontend_htaccess && substr( $frontend_htaccess, -10 ) === '/.htaccess' ) {
$this->frontend_htaccess = $frontend_htaccess;
}
$backend_htaccess = $this->conf( Base::O_MISC_HTACCESS_BACK );
$backend_htaccess = defined( 'LITESPEED_CFG_HTACCESS_BACKEND' ) ? LITESPEED_CFG_HTACCESS_BACKEND : false;
if ( $backend_htaccess && substr( $backend_htaccess, -10 ) === '/.htaccess' ) {
$this->backend_htaccess = $backend_htaccess;
}
Expand Down Expand Up @@ -280,30 +278,6 @@ public function htaccess_read( $kind = 'frontend' ) {
return $content;
}

/**
* Save the rules file changes.
*
* NOTE: will throw error if failed
*
* @since 1.0.4
* @access public
*/
public function htaccess_save( $content, $kind = 'frontend' ) {
$path = $this->htaccess_path( $kind );

if ( ! $this->writable( $kind ) ) {
Error::t( 'HTA_W' );
}

$this->_htaccess_backup( $kind );

// File put contents will truncate by default. Will create file if doesn't exist.
$res = File::save( $path, $content, false, false, false );
if ( $res !== true ) {
throw new \Exception( $res );
}
}

/**
* Try to backup the .htaccess file if we didn't save one before.
*
Expand Down Expand Up @@ -852,31 +826,5 @@ public function clear_rules() {
$this->_insert_wrapper( false, 'backend', self::MARKER_NONLS );
}
}

/**
* Parses the .htaccess buffer when the admin saves changes in the edit .htaccess page.
* Only admin can do this
*
* @since 1.0.4
* @since 2.9 Used exception when saving
* @access public
*/
public function htaccess_editor_save() {
if ( ! isset( $_POST[ self::EDITOR_TEXTAREA_NAME ] ) ) {
return;
}

$content = Admin::cleanup_text($_POST[self::EDITOR_TEXTAREA_NAME]);

try {
$this->htaccess_save($content);
} catch( \Exception $e ) {
Admin_Display::error( $e->getMessage() );
return;
}

Admin_Display::succeed( __( 'File Saved.', 'litespeed-cache' ) );

}
}

2 changes: 0 additions & 2 deletions src/lang.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ public static function title( $id )
self::O_CACHE_LOGIN_COOKIE => __( 'Login Cookie', 'litespeed-cache' ),
self::O_IMG_OPTM_WEBP_REPLACE => __( 'Image WebP Replacement', 'litespeed-cache' ),

self::O_MISC_HTACCESS_FRONT => __( 'Frontend .htaccess Path', 'litespeed-cache' ),
self::O_MISC_HTACCESS_BACK => __( 'Backend .htaccess Path', 'litespeed-cache' ),
self::O_MISC_HEARTBEAT_FRONT => __( 'Frontend Heartbeat Control', 'litespeed-cache' ),
self::O_MISC_HEARTBEAT_FRONT_TTL => __( 'Frontend Heartbeat TTL', 'litespeed-cache' ),
self::O_MISC_HEARTBEAT_BACK => __( 'Backend Heartbeat Control', 'litespeed-cache' ),
Expand Down
8 changes: 0 additions & 8 deletions src/router.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class Router extends Base {
const NONCE = 'LSCWP_NONCE';
const ACTION = 'LSCWP_CTRL';

const ACTION_SAVE_HTACCESS = 'save-htaccess';
const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network';
const ACTION_DB_OPTM = 'db_optm';
const ACTION_PLACEHOLDER = 'placeholder';
Expand Down Expand Up @@ -517,13 +516,6 @@ private function verify_action() {
$_can_option = current_user_can( 'manage_options' );

switch ( $action ) {
// Save htaccess
case self::ACTION_SAVE_HTACCESS:
if ( ( ! $_is_multisite && $_can_option ) || $_can_network_option ) {
self::$_action = $action;
}
return;

// Save network settings
case self::ACTION_SAVE_SETTINGS_NETWORK:
if ( $_can_network_option ) {
Expand Down
61 changes: 20 additions & 41 deletions tpl/toolbox/edit_htaccess.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
namespace LiteSpeed;
defined( 'WPINC' ) || exit;

$readonly = Htaccess::cls()->writable() ? '' : 'readonly';

$content = null;
try {
$content = Htaccess::cls()->htaccess_read();
Expand Down Expand Up @@ -35,75 +33,56 @@
?>

<h3 class="litespeed-title">
<?php echo __('LiteSpeed Cache Edit .htaccess', 'litespeed-cache'); ?>
<?php echo __('LiteSpeed Cache View .htaccess', 'litespeed-cache'); ?>
<?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#edit-htaccess-tab' ); ?>
</h3>

<div class="litespeed-callout notice notice-error inline">
<h4>🚨 <?php echo __('This page is meant for advanced users.', 'litespeed-cache'); ?></h4>
<p>
<?php echo __('Any changes made to the .htaccess file may break the site.', 'litespeed-cache'); ?>
<?php echo __('Please consult the host/server admin before making any changes.', 'litespeed-cache'); ?>
</p>
</div>

<?php $this->form_action( $this->_is_network_admin ? Router::ACTION_SAVE_SETTINGS_NETWORK : false ); ?>

<h3 class="litespeed-title-short">
<?php echo __( '.htaccess Path Settings', 'litespeed-cache' ); ?>
<?php echo __( '.htaccess Path', 'litespeed-cache' ); ?>
</h3>

<table class="wp-list-table striped litespeed-table"><tbody>
<tr>
<th>
<?php $id = Base::O_MISC_HTACCESS_FRONT; ?>
<?php $this->title( $id ); ?>
<?php echo __( 'Frontend .htaccess Path', 'litespeed-cache' ); ?>
</th>
<td>
<?php $this->build_input( $id, 'litespeed-input-long' ); ?>
<code><?php echo $htaccess_path; ?></code>
<div class="litespeed-desc">
<?php echo __( 'Specify the frontend .htaccess path.', 'litespeed-cache' ); ?>
<?php echo __( 'Leave empty to auto detect', 'litespeed-cache' ); ?>: <code><?php echo Htaccess::get_frontend_htaccess( true ); ?></code>
<?php $this->_validate_htaccess_path( $id ); ?>
<?php echo __( 'Default path is', 'litespeed-cache' ); ?>: <code><?php echo Htaccess::get_frontend_htaccess( true ); ?></code>
<br /><font class="litespeed-success">
<?php echo __( 'API', 'litespeed-cache' ); ?>:
<?php echo sprintf( __( 'PHP Constant %s is supported.', 'litespeed-cache' ), '<code>LITESPEED_CFG_HTACCESS</code>' ); ?>
<?php echo sprintf( __( 'You can use this code %1$s in %2$s to specify the htaccess file path.', 'litespeed-cache' ), '<code>defined("LITESPEED_CFG_HTACCESS") || define("LITESPEED_CFG_HTACCESS", "your path on server");</code>', '<code>wp-config.php</code>' ); ?>
</font>
</div>
</td>
</tr>

<tr>
<th>
<?php $id = Base::O_MISC_HTACCESS_BACK; ?>
<?php $this->title( $id ); ?>
<?php echo __( 'Backend .htaccess Path', 'litespeed-cache' ); ?>
</th>
<td>
<?php $this->build_input( $id, 'litespeed-input-long' ); ?>
<?php echo Htaccess::get_backend_htaccess(); ?>
<div class="litespeed-desc">
<?php echo __( 'Specify the backend .htaccess path.', 'litespeed-cache' ); ?>
<?php echo __( 'Leave empty to auto detect', 'litespeed-cache' ); ?>: <code><?php echo Htaccess::get_backend_htaccess( true ); ?></code>
<?php $this->_validate_htaccess_path( $id ); ?>
<?php echo __( 'Default path is', 'litespeed-cache' ); ?>: <code><?php echo Htaccess::get_backend_htaccess( true ); ?></code>
<br /><font class="litespeed-success">
<?php echo __( 'API', 'litespeed-cache' ); ?>:
<?php echo sprintf( __( 'PHP Constant %s is supported.', 'litespeed-cache' ), '<code>LITESPEED_CFG_HTACCESS_BACKEND</code>' ); ?>
<?php echo sprintf( __( 'You can use this code %1$s in %2$s to specify the htaccess file path.', 'litespeed-cache' ), '<code>defined("LITESPEED_CFG_HTACCESS_BACKEND") || define("LITESPEED_CFG_HTACCESS_BACKEND", "your path on server");</code>', '<code>wp-config.php</code>' ); ?>
</font>
</div>
</td>
</tr>
</tbody></table>

<?php $this->form_end( $this->_is_network_admin ); ?>

<?php if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) : ?>
<div class="litespeed-h3"><?php echo __('File editing is disabled in configuration.', 'litespeed-cache'); ?></div>

<?php elseif( $content !== null ) : ?>

<?php $this->form_action( Router::ACTION_SAVE_HTACCESS ); ?>
<?php if( $content !== null ) : ?>

<h3 class="litespeed-title"><?php echo sprintf(__('Current %s Contents', 'litespeed-cache'), '.htaccess'); ?></h3>

<p><span class="attention"><?php echo sprintf(__('DO NOT EDIT ANYTHING WITHIN %s', 'litespeed-cache'), '<code>' . Htaccess::LS_MODULE_DONOTEDIT . '</code>' ); ?></span></p>

<h4><?php echo $htaccess_path; ?></h4>

<textarea name="<?php echo Htaccess::EDITOR_TEXTAREA_NAME; ?>" wrap="off" rows="50" class="large-text"
<?php echo $readonly; ?>
><?php echo esc_textarea($content); ?></textarea>
<p><button type="submit" class="button button-primary"><?php echo __('Save .htaccess', 'litespeed-cache'); ?></button></p>
</form>
<textarea readonly wrap="off" rows="50" class="large-text"><?php echo esc_textarea($content); ?></textarea>

<?php endif; ?>
2 changes: 1 addition & 1 deletion tpl/toolbox/entry.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}

if ( ! $this->_is_multisite || $this->_is_network_admin ) {
$menu_list[ 'edit_htaccess' ] = __( 'Edit .htaccess', 'litespeed-cache' );
$menu_list[ 'edit_htaccess' ] = __( 'View .htaccess', 'litespeed-cache' );
}

if ( ! $this->_is_network_admin ) {
Expand Down

0 comments on commit 23f4041

Please sign in to comment.