Skip to content

Commit f46592c

Browse files
CDN - Move file type include to init
1 parent d5fb6a2 commit f46592c

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

src/cdn.cls.php

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ public function init()
9494
Debug2::debug2('[CDN] mapping ' . implode(',', $v[Base::CDN_MAPPING_FILETYPE]) . ' -> ' . $this_url);
9595
}
9696
}
97+
98+
// Add CSS to rewrite if CDN Mapping setting is enabled
99+
if (!empty($this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_CSS])) {
100+
$this->_cfg_cdn_mapping['.css'] = $this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_CSS];
101+
}
102+
103+
// Add JS to rewrite if CDN Mapping setting is enabled
104+
if (!empty($this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_JS])) {
105+
$this->_cfg_cdn_mapping['.js'] = $this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_JS];
106+
}
97107

98108
if (!$this->_cfg_url_ori || !$this->_cfg_cdn_mapping) {
99109
if (!defined(self::BYPASS)) {
@@ -209,28 +219,9 @@ private function _finalize()
209219
$this->_replace_inline_css();
210220
}
211221

212-
// Temporary add file types to mapping filetype rewrite
213-
// Add CSS
214-
if (!empty($this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_CSS])) {
215-
$this->_cfg_cdn_mapping['.css'] = $this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_CSS];
216-
}
217-
218-
// Add JS
219-
if (!empty($this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_JS])) {
220-
$this->_cfg_cdn_mapping['.js'] = $this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_JS];
221-
}
222-
223222
if (!empty($this->_cfg_cdn_mapping[Base::CDN_MAPPING_FILETYPE])) {
224223
$this->_replace_file_types();
225224
}
226-
227-
// Remove temporary file types added to mapping filetype rewrite
228-
if (!empty($this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_CSS])) {
229-
unset($this->_cfg_cdn_mapping['.css']);
230-
}
231-
if (!empty($this->_cfg_cdn_mapping[Base::CDN_MAPPING_INC_JS])) {
232-
unset($this->_cfg_cdn_mapping['.js']);
233-
}
234225
}
235226

236227
/**

0 commit comments

Comments
 (0)