public function glmsimplemessageboardAddSettingField($name, $label, $type, $simpleMessageboardSection)
{
switch ($type) {
+ case 'number':
+ $callback = 'glmsimplemessageboardRenderNumber';
+ break;
case 'text':
$callback = 'glmsimplemessageboardRenderText';
break;
'label' => 'Message',
'type' => 'textarea'
),
+ array(
+ 'name' => 'characterlimit',
+ 'label' => 'Character Limit',
+ 'type' => 'number'
+ ),
);
foreach ($fieldNames as $field) {
}
}
+ 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;
--- /dev/null
+
+
+<?php
+// This does not seem to restrct on privileges properly
+// e.g. current_user_can("bluriglurp") also passes as true
+if ( current_user_can( "manage_options" ) ) { ?>
+ <input type="number" min="0" step="1" max="99999" name="glmsimplemessageboard_settings[<?php echo $fieldName;?>]"
+ value="<?php echo str_replace( '"', '"e;', $options[$fieldName] ); ?>">
+<?php } ?>
<input type="text" name="glmsimplemessageboard_settings[<?php echo $fieldName;?>]"
- value="<?php echo str_replace('"', '"e;', $options[$fieldName]); ?>">
-<?php
\ No newline at end of file
+ value="<?php echo str_replace('"', '"e;', $options[$fieldName]); ?>">
\ No newline at end of file
-<textarea class='message' cols="40" maxlength="220" rows="5" name="glmsimplemessageboard_settings[<?php echo $fieldName;?>]"><?php echo htmlspecialchars($options[$fieldName]); ?></textarea>
+<?php
+ if ($options && array_key_exists( 'characterlimit', $options ) ) {
+ $characterLimit = $options['characterlimit'];
+ } else {
+ $characterLimit = "250";
+ }
+?>
+
+<textarea class='message' cols="40" maxlength="<?php echo $characterLimit ?>" rows="5" name="glmsimplemessageboard_settings[<?php echo $fieldName;?>]"><?php echo htmlspecialchars($options[$fieldName]); ?></textarea>
<br><span class="countdown"></span>
<script type="text/javascript">
+
+ var characterLimit = <?php echo $characterLimit ?>;
+
function updateCountdown() {
- // 220 is the max message length
- var remaining = 220 - jQuery('.message').val().length;
+ var remaining = characterLimit - jQuery('.message').val().length;
jQuery('.countdown').text(remaining + ' characters remaining.');
}
jQuery(document).ready(function($) {