From: Laury GvR Date: Wed, 1 Mar 2017 21:16:02 +0000 (-0500) Subject: number field for restricting the textarea chars X-Git-Tag: v1.0.13^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=a5a834c48763924cf5f5d9bd48cccaac39802c66;p=WP-Plugins%2Fglm-simple-messageboard.git number field for restricting the textarea chars Number field type added for the creation of a character amount restriction to be used for the textarea field, which can be edited in the admin side if the user has manage_options - except it seems to currently pass current_user_can too easily, no matter what it checks against. --- diff --git a/controllers/Admin.php b/controllers/Admin.php index 9e5ac9e..a58b565 100644 --- a/controllers/Admin.php +++ b/controllers/Admin.php @@ -98,6 +98,9 @@ class Glmsimplemessageboard_Admin_Controller public function glmsimplemessageboardAddSettingField($name, $label, $type, $simpleMessageboardSection) { switch ($type) { + case 'number': + $callback = 'glmsimplemessageboardRenderNumber'; + break; case 'text': $callback = 'glmsimplemessageboardRenderText'; break; @@ -151,6 +154,11 @@ class Glmsimplemessageboard_Admin_Controller 'label' => 'Message', 'type' => 'textarea' ), + array( + 'name' => 'characterlimit', + 'label' => 'Character Limit', + 'type' => 'number' + ), ); foreach ($fieldNames as $field) { @@ -164,6 +172,15 @@ class Glmsimplemessageboard_Admin_Controller } } + public function glmsimplemessageboardRenderNumber($fieldName) + { + static $options; + if (!$options) { + $options = get_option(GLM_SIMPLEMESSAGEBOARD_SETTINGS); + } + include $this->path . 'views/number.php'; + } + public function glmsimplemessageboardRenderText($fieldName) { static $options; diff --git a/views/number.php b/views/number.php new file mode 100644 index 0000000..9d565ad --- /dev/null +++ b/views/number.php @@ -0,0 +1,9 @@ + + + + "> + diff --git a/views/text.php b/views/text.php index d58813c..6342536 100644 --- a/views/text.php +++ b/views/text.php @@ -1,3 +1,2 @@ "> -"> \ No newline at end of file diff --git a/views/textArea.php b/views/textArea.php index 7c5d976..fdd41e3 100644 --- a/views/textArea.php +++ b/views/textArea.php @@ -1,9 +1,19 @@ - + + +