From 28e87414db5516d05bff26d448e67d6d52ce9eec Mon Sep 17 00:00:00 2001 From: Jon Gilkison Date: Wed, 15 Jun 2016 19:34:48 +0700 Subject: [PATCH] Fix trailing slash on CDN Add select option --- classes/ilab-media-tool-base.php | 33 +++++++++++++++++++++++++ classes/tools/s3/ilab-media-s3-tool.php | 3 +++ tools.json | 14 ++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/classes/ilab-media-tool-base.php b/classes/ilab-media-tool-base.php index af304f16..554d3967 100644 --- a/classes/ilab-media-tool-base.php +++ b/classes/ilab-media-tool-base.php @@ -42,6 +42,8 @@ abstract class ILabMediaToolBase { */ protected $options_group; + private $select_options = []; + /** * Creates a new instance. Subclasses should do any setup dependent on being enabled in setup() * @param $toolName @@ -167,6 +169,9 @@ public function registerSettings() case 'number': $this->registerNumberFieldSetting($option,$optionInfo['title'],$group,(isset($optionInfo['description']) ? $optionInfo['description'] : null)); break; + case 'select': + $this->registerSelectSetting($option,$optionInfo['options'],$optionInfo['title'],$group,(isset($optionInfo['description']) ? $optionInfo['description'] : null)); + break; } } } @@ -307,6 +312,34 @@ public function renderNumberFieldSetting($args) echo "

".$args['description']."

"; } + protected function registerSelectSetting($option_name,$options,$title,$settings_slug,$description=null) + { + $this->select_options[$option_name] = $options; + add_settings_field($option_name,$title,[$this,'renderSelectSetting'],$this->options_page,$settings_slug,['option'=>$option_name,'description'=>$description]); + } + + public function renderSelectSetting($args) + { + $option = $args['option']; + $options = $this->select_options[$option]; + + $value=get_option($args['option']); + + echo "