Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Patch to fix checkbox display in Custom Metadata Manager WordPress Plugin

View gist:1725905
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
Index: custom_metadata.php
===================================================================
--- custom_metadata.php (revision 499358)
+++ custom_metadata.php (working copy)
@@ -871,12 +871,22 @@
else $field_id = $field_slug;
$readonly_str = ($field->readonly) ? 'readonly="readonly" ' : '';
+
if (get_post_type()) $numb = $post->ID; else $numb = 1; ?>
<script>var numb = '<?php echo $numb ?>'; </script>
- <label for="<?php echo $field_slug; ?>"><?php echo $field->label; ?></label>
- <?php
+ <?php
+ // Set up the <label> tag for this field.
+ $label_str = "<label for='$field_slug'>{$field->label}</label>";
+
+ // Define an array of field types that need the <label> AFTER the <input>
+ $label_after_field_types = array('checkbox');
+
+ // Show the label now if the current field_type is not on the list
+ if ( !in_array( $field->field_type, $label_after_field_types ) )
+ echo $label_str;
+
// make sure $value is an array
if (!$value) $value = ''; // if empty, give it an empty string instead
$value = (array)$value;
@@ -968,14 +978,17 @@
<?php break; ?>
<?php endswitch; ?>
-
<?php if ($count > 1) : ?>
<a href="#" class="del-multiple hide-if-no-js" style="color:red;">Delete</a>
<?php endif; $count++ ?>
</div>
-
- <?php endforeach; ?>
+ <?php
+ // Now show the <label> for any field_type that needs it to come after
+ if ( in_array( $field->field_type, $label_after_field_types ) )
+ echo $label_str;
+
+ endforeach; ?>
<?php if (isset($field->multiple) && $field->multiple) : ?>
<p><a href="#" class="add-multiple hide-if-no-js" id="add-<?php echo $field_slug ?>">+ Add New</a></p>
<?php endif;?>
Index: css/custom-metadata-manager.css
===================================================================
--- css/custom-metadata-manager.css (revision 499358)
+++ css/custom-metadata-manager.css (working copy)
@@ -13,7 +13,9 @@
.custom-metadata-field > div > label > input[type=radio] {margin-right: 5px;}
/* checkbox fields */
-.custom-metadata-field.checkbox {background: transparent}
+.custom-metadata-field.checkbox {background: transparent;}
+.custom-metadata-field.checkbox div, .custom-metadata-field.checkbox label {display: inline-block;}
+.custom-metadata-field.checkbox input {margin: 0 1px 0 0;}
/* upload fields */
.custom-metadata-field input.upload_field {width: 60%;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.