Skip to content

Commit 76c8525

Browse files
V7_7_links (#944)
1 parent abde8a5 commit 76c8525

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/css.cls.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,14 @@ private function _gen_ccss_file_tag( $request_url ) {
135135
*/
136136
private function _ccss() {
137137
global $wp;
138-
$request_url = get_permalink();
139-
// Backup, in case get_permalink() fails.
140-
if ( ! $request_url ) {
141-
$request_url = home_url( $wp->request );
138+
139+
// get current request url
140+
$permalink_structure = get_option( 'permalink_structure' );
141+
if ( ! empty( $permalink_structure ) ) {
142+
$request_url = trailingslashit( home_url( $wp->request ) );
143+
} else {
144+
$qs_add = $wp->query_string ? '?' . (string) $wp->query_string : '' ;
145+
$request_url = home_url( $wp->request ) . $qs_add;
142146
}
143147

144148
$filepath_prefix = $this->_build_filepath_prefix( 'ccss' );

src/optimize.cls.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,14 @@ private function _finalize( $content ) {
274274
*/
275275
private function _optimize() {
276276
global $wp;
277-
$this->_request_url = get_permalink();
278-
// Backup, in case get_permalink() fails.
279-
if (!$this->_request_url) {
280-
$this->_request_url = home_url($wp->request);
277+
278+
// get current request url
279+
$permalink_structure = get_option( 'permalink_structure' );
280+
if ( ! empty( $permalink_structure ) ) {
281+
$this->_request_url = trailingslashit( home_url( $wp->request ) );
282+
} else {
283+
$qs_add = $wp->query_string ? '?' . (string) $wp->query_string : '' ;
284+
$this->_request_url = home_url( $wp->request ) . $qs_add;
281285
}
282286

283287
$this->cfg_css_min = defined('LITESPEED_GUEST_OPTM') || $this->conf(self::O_OPTM_CSS_MIN);

src/purge.cls.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,11 @@ public static function purge_ucss( $post_id_or_url ) {
331331
$post_id_or_url = get_permalink( (int) $post_id_or_url );
332332
}
333333

334-
$post_id_or_url = untrailingslashit( (string) $post_id_or_url );
334+
$post_id_or_url = (string) $post_id_or_url;
335+
$permalink_structure = get_option( 'permalink_structure' );
336+
if ( ! empty( $permalink_structure ) ) {
337+
$post_id_or_url = trailingslashit( (string) $post_id_or_url );
338+
}
335339

336340
$existing_url_files = Data::cls()->mark_as_expired( $post_id_or_url, true );
337341
if ( $existing_url_files ) {

0 commit comments

Comments
 (0)