From 429a14027f15964c5747f6071f8d1d311d0cd58a Mon Sep 17 00:00:00 2001 From: Matt Boynes Date: Wed, 29 Jul 2015 09:14:21 -0400 Subject: [PATCH 1/2] Update prepare_data() to better use the passed field --- php/context/class-fieldmanager-context.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/php/context/class-fieldmanager-context.php b/php/context/class-fieldmanager-context.php index 5051d5af11..5ed0cdda6b 100644 --- a/php/context/class-fieldmanager-context.php +++ b/php/context/class-fieldmanager-context.php @@ -51,7 +51,7 @@ protected function is_valid_nonce() { * * @param mixed $old_value Optional. The previous value. * @param mixed $new_value Optional. The new value for the field. - * @param object $fm Optional. The Fieldmanager field to prepare. + * @param object $fm Optional. The Fieldmanager_Field to prepare. * @return mixed The filtered and sanitized value, safe to save. */ protected function prepare_data( $old_value = null, $new_value = null, $fm = null ) { @@ -59,11 +59,11 @@ protected function prepare_data( $old_value = null, $new_value = null, $fm = nul $fm = $this->fm; } if ( null === $new_value ) { - $new_value = isset( $_POST[ $this->fm->name ] ) ? $_POST[ $this->fm->name ] : ''; + $new_value = isset( $_POST[ $fm->name ] ) ? $_POST[ $fm->name ] : ''; } - $new_value = apply_filters( "fm_context_before_presave_data", $new_value, $old_value, $this ); + $new_value = apply_filters( "fm_context_before_presave_data", $new_value, $old_value, $this, $fm ); $data = $fm->presave_all( $new_value, $old_value ); - return apply_filters( "fm_context_after_presave_data", $data, $old_value, $this ); + return apply_filters( "fm_context_after_presave_data", $data, $old_value, $this, $fm ); } From 03898ead2e99985d3f4fcc5b574891786c5f5038 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Sat, 20 Feb 2016 08:02:45 -0800 Subject: [PATCH 2/2] Revert change that we don't know if it won't have unexpected consequences --- php/context/class-fieldmanager-context.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/context/class-fieldmanager-context.php b/php/context/class-fieldmanager-context.php index 5ed0cdda6b..2cc53df08f 100644 --- a/php/context/class-fieldmanager-context.php +++ b/php/context/class-fieldmanager-context.php @@ -59,7 +59,7 @@ protected function prepare_data( $old_value = null, $new_value = null, $fm = nul $fm = $this->fm; } if ( null === $new_value ) { - $new_value = isset( $_POST[ $fm->name ] ) ? $_POST[ $fm->name ] : ''; + $new_value = isset( $_POST[ $this->fm->name ] ) ? $_POST[ $this->fm->name ] : ''; } $new_value = apply_filters( "fm_context_before_presave_data", $new_value, $old_value, $this, $fm ); $data = $fm->presave_all( $new_value, $old_value ); @@ -93,4 +93,4 @@ protected function render_field( $args = array() ) { } } -} \ No newline at end of file +}