From c9d7f60133bca467d2eac43fa401bc996c23e6cf Mon Sep 17 00:00:00 2001 From: kurtw Date: Wed, 10 Jun 2015 10:32:18 -0400 Subject: [PATCH] Fix saving bug --- CHANGELOG.md | 5 +++++ cms-toolkit.php | 2 +- inc/meta-box-models.php | 6 ++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b00939..0c90f12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. We follow the [Semantic Versioning 2.0.0](http://semver.org/) format. +## 2.0.2 - 2015-06-09 + +### Changed +- Fix bug that caused empty links to interrupt saving of fields that followed + ## 2.0.1 - 2015-06-02 ### Changed diff --git a/cms-toolkit.php b/cms-toolkit.php index a23f9d1..b516e05 100644 --- a/cms-toolkit.php +++ b/cms-toolkit.php @@ -13,7 +13,7 @@ available throughout the application and make building complex functionality in WordPress a little easier. -Version: 2.0.1 +Version: 2.0.2 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 diff --git a/inc/meta-box-models.php b/inc/meta-box-models.php index 33e5406..df13dc5 100644 --- a/inc/meta-box-models.php +++ b/inc/meta-box-models.php @@ -239,7 +239,7 @@ public function validate_link( $key, &$validated ) { $url = $_POST["{$key}_url"]; $full_link = array( 'label' => $label, 'url' => $url ); - $validated = ( empty( $label ) or empty( $url ) ) ? null : $full_link; + $validated = ( empty( $label ) or empty( $url ) ) ? "" : $full_link; } } @@ -551,8 +551,6 @@ public static function save( $post_ID, $postvalues ) { $existing = get_post_meta( $post_ID, $key, $single = true ); if ( isset( $value ) ) { update_post_meta( $post_ID, $key = $key, $meta_value = $value ); - } else { - return; } } } @@ -580,7 +578,7 @@ public function validate_and_save( $post_ID ) { $this->fields[$key]['key'] = $this->fields[$key]['old_key']; //create keys in array that are to be saved - $validated[$this->fields[$key]['old_key']] = null; + $validated[$this->fields[$key]['old_key']] = ""; // retrieve saved data $saved[$this->fields[$key]['old_key']] = get_post_meta( $post_ID, $this->fields[$key]['old_key'], $single = true );