From df3772776356a6904b8a4d8ea74a0bfab89a507c Mon Sep 17 00:00:00 2001 From: Jeff Stieler <jeff.m.stieler@gmail.com> Date: Tue, 16 Aug 2011 11:30:49 -0400 Subject: [PATCH] Set CSS/JS CDN urls default to the root if not specified. --- cdn-rewrite.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cdn-rewrite.php b/cdn-rewrite.php index 9afadb1..5ed3af7 100644 --- a/cdn-rewrite.php +++ b/cdn-rewrite.php @@ -28,15 +28,20 @@ class CDN_Rewrite { private $blog_details; public function __construct() { - $this->cdn_root_url = untrailingslashit($this->get_setting('root_url')); - $this->file_extensions = $this->get_setting('file_extensions'); + $this->cdn_root_url = $this->css_cdn_root_url = $this->js_cdn_root_url = untrailingslashit($this->get_setting('root_url')); - $this->css_cdn_root_url = untrailingslashit($this->get_setting('css_root_url')); - $this->css_file_extensions = $this->get_setting('css_file_extensions'); + if ($css_url = trim($this->get_setting('css_root_url'))) { + $this->css_cdn_root_url = untrailingslashit($css_url); + } + + if ($js_url = trim($this->get_setting('js_root_url'))) { + $this->js_cdn_root_url = untrailingslashit($js_url); + } - $this->js_cdn_root_url = untrailingslashit($this->get_setting('js_root_url')); + $this->file_extensions = $this->get_setting('file_extensions'); + $this->css_file_extensions = $this->get_setting('css_file_extensions'); $this->js_file_extensions = $this->get_setting('js_file_extensions'); -} + } public function initialize() { if (!class_exists('Voce_Settings')) { @@ -92,8 +97,8 @@ class CDN_Rewrite { $section->add_field('file_extensions', 'File Extensions (required)', 'field_input'); $section->add_field('css_root_url', 'CDN Root URL for CSS Files (optional)', 'field_input', array('description' => 'The base URL of the CDN for CSS Files.')); $section->add_field('css_file_extensions', 'File Extensions for CSS Files (optional)', 'field_input'); - $section->add_field('js_root_url', 'CDN Root URL for JS Files (optional)', 'field_input', array('description' => 'The base URL of the CDN for JS Files.')); - $section->add_field('js_file_extensions', 'File Extensions for JS Files (optional)', 'field_input'); + $section->add_field('js_root_url', 'CDN Root URL for JS Files (optional, defaults to Root URL)', 'field_input', array('description' => 'The base URL of the CDN for JS Files.')); + $section->add_field('js_file_extensions', 'File Extensions for JS Files (optional, defaults to Root URL)', 'field_input'); } /** -- GitLab