Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #131 from zamoose/master

Patch for Farbtastic colorpicker
  • Loading branch information...
commit 3058a18d1b43604c12eb1ef113f3b96826b972f2 2 parents 88875a8 + 58a1865
Jared Atchison authored
Showing with 18 additions and 1 deletion.
  1. +18 −1 init.php
View
19 init.php
@@ -223,7 +223,24 @@ function show() {
echo '$ <input class="cmb_text_money" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" /><span class="cmb_metabox_description">', $field['desc'], '</span>';
break;
case 'colorpicker':
- echo '<input class="cmb_colorpicker cmb_text_small" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" /><span class="cmb_metabox_description">', $field['desc'], '</span>';
+ if( '' !== $meta ) {
+ if( preg_match('/^(([a-fA-F0-9]){3}){1,2}$/i', $meta ) ){
+ $meta = '#' . $meta;
+ } elseif( preg_match('/^#(([a-fA-F0-9]){3}){1,2}$/i', $meta ) ) {
+
+ } else {
+ $meta = "#";
+ }
+ } else {
+ if( preg_match('/^(([a-fA-F0-9]){3}){1,2}$/i', $field['std'] ) ){
+ $meta = '#' . $field['std'];
+ } elseif( preg_match('/^#(([a-fA-F0-9]){3}){1,2}$/i', $field['std'] ) ) {
+ $meta = $field['std'];
+ } else {
+ $meta = "#";
+ }
+ }
+ echo '<input class="cmb_colorpicker cmb_text_small" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta, '" /><span class="cmb_metabox_description">', $field['desc'], '</span>';
break;
case 'textarea':
echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="10">', '' !== $meta ? $meta : $field['std'], '</textarea>','<p class="cmb_metabox_description">', $field['desc'], '</p>';
Please sign in to comment.
Something went wrong with that request. Please try again.