Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Commit

Permalink
Merge pull request #52 from kurtw/bugs
Browse files Browse the repository at this point in the history
Fix bugs, add link label formatting, add howto to formsets
  • Loading branch information
Scotchester committed Mar 27, 2015
2 parents 0074636 + 942405b commit dc73973
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cms-toolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
available throughout the application and make building complex functionality
in WordPress a little easier.
Version: 1.5.0
Version: 1.5.1
Author: Greg Boone, Aman Kaur, Matthew Duran, Scott Cranfill, Kurt Wall
Author URI: https://github.com/cfpb/
License: Public Domain work of the Federal Government
Expand Down
13 changes: 8 additions & 5 deletions inc/meta-box-html.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function draw( $field, $form_id = NULL ) {
} elseif ( $field['type'] == 'nonce' ) {
wp_nonce_field( plugin_basename( __FILE__ ), $field['meta_key'] );
}
if ( isset( $field['howto'] ) ) {
if ( isset( $field['howto'] ) and $field['type'] != 'formset' ) {
?><p class="howto"><?php echo esc_attr( $field['howto'] ) ?></p><?php
}
?></div><?php
Expand All @@ -61,6 +61,9 @@ public function draw_formset( $field ) {
if ( empty( $existing ) and ! $init ) { echo " hidden"; }
?>" href="#remove-formset_<?php echo $form_id; ?>">Remove</a><?php
?></h4><?php
if ( isset( $field['howto'] ) ) {
?><p class="howto"><?php echo esc_attr( $field['howto'] ) ?></p><?php
}
foreach ($field['fields'] as $f) {
$this->draw( $f, $form_id );
}
Expand Down Expand Up @@ -305,11 +308,11 @@ public function link_input( $meta_key, $value, $required, $label, $form_id = NUL
$existing = get_post_meta( $post_id, $meta_key, false);
?><div class="link-field <?php echo "{$meta_key}" ?>"><?php
if ( ! isset( $existing[0] ) || ! isset( $existing[1] ) ) {
$this->single_input( $meta_key . "_text", $value, 'text', $required, NULL, 'Text', 'Url text here', $form_id );
$this->single_input( $meta_key . "_url", $value, 'url', $required, NULL, 'URL', 'Url here', $form_id );
$this->single_input( $meta_key . "_text", $value, 'text', $required, NULL, 'Link Text', 'Url text here', $form_id );
$this->single_input( $meta_key . "_url", $value, 'url', $required, NULL, 'Link URL', 'Url here', $form_id );
} else {
$this->single_input( $meta_key . "_text", $existing[1], 'text', $required, NULL, 'Text', NULL, $form_id );
$this->single_input( $meta_key . "_url", $existing[0], 'url', $required, NULL, 'URL', NULL, $form_id );
$this->single_input( $meta_key . "_text", $existing[1], 'text', $required, NULL, 'Link Text', NULL, $form_id );
$this->single_input( $meta_key . "_url", $existing[0], 'url', $required, NULL, 'Link URL', NULL, $form_id );
}
?></div><?php
}
Expand Down
12 changes: 6 additions & 6 deletions inc/meta-box-models.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,14 @@ public function validate_datetime($field, $post_ID) {
}
if ( $field['type'] == 'date' ) {
$date = DateTime::createFromFormat('F j Y', $data[$field['taxonomy']]);
} elseif ( $field['type'] == 'time' ) {
if ( isset( $_POST[$field['taxonomy'] . '_timezone'] ) )
date_default_timezone_set( $_POST[$field['taxonomy'] . '_timezone'][0] );
$date = DateTime::createFromFormat('h:ia T', $data[$field['taxonomy']]);
} elseif ( $field['type'] == 'datetime' ) {
} else {
if ( isset( $_POST[$field['taxonomy'] . '_timezone'] ) )
date_default_timezone_set( $_POST[$field['taxonomy'] . '_timezone'][0] );
$date = DateTime::createFromFormat('F j Y h:ia T', $data[$field['taxonomy']]);
if ( $field['type'] == 'time' ) {
$date = DateTime::createFromFormat('h:ia T', $data[$field['taxonomy']]);
} elseif ( $field['type'] == 'datetime' ) {
$date = DateTime::createFromFormat('F j Y h:ia T', $data[$field['taxonomy']]);
}
}
if ( $date ) {
$this->Callbacks->date( $post_ID, $field['taxonomy'], $multiple = $field['multiple'], $data, null );
Expand Down
3 changes: 3 additions & 0 deletions inc/meta-box-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ class View {
);
private $inputs = array(
'text_area',
'wysiwyg',
'number',
'text',
'boolean',
'email',
'url',
'date',
'time',
'datetime',
'radio',
'link',
);
Expand Down

0 comments on commit dc73973

Please sign in to comment.