| @@ -64,9 +64,8 @@ | ||
| 64 | 64 | /** |
| 65 | 65 | * Gets entry property. |
| 66 | 66 | * |
| 67 | 67 | * @since 5.0.16 |
| 68 | - * | |
| 69 | 68 | * @return stdClass |
| 70 | 69 | */ |
| 71 | 70 | public function get_entry() { |
| 72 | 71 | return $this->entry; |
| @@ -115,10 +114,8 @@ | ||
| 115 | 114 | * |
| 116 | 115 | * @since 2.05.06 |
| 117 | 116 | * |
| 118 | 117 | * @param string $value |
| 119 | - * | |
| 120 | - * @return mixed | |
| 121 | 118 | */ |
| 122 | 119 | public function get_field_option( $value ) { |
| 123 | 120 | return FrmField::get_option( $this->field, $value ); |
| 124 | 121 | } |
| @@ -126,10 +123,8 @@ | ||
| 126 | 123 | /** |
| 127 | 124 | * @since 4.03 |
| 128 | 125 | * |
| 129 | 126 | * @param string $option |
| 130 | - * | |
| 131 | - * @return mixed | |
| 132 | 127 | */ |
| 133 | 128 | public function get_field_attr( $option ) { |
| 134 | 129 | return is_object( $this->field ) ? $this->field->{$option} : ''; |
| 135 | 130 | } |
| @@ -146,10 +141,8 @@ | ||
| 146 | 141 | /** |
| 147 | 142 | * Get the field property's label |
| 148 | 143 | * |
| 149 | 144 | * @since 2.04 |
| 150 | - * | |
| 151 | - * @return string | |
| 152 | 145 | */ |
| 153 | 146 | public function get_field_label() { |
| 154 | 147 | return $this->get_field_attr( 'name' ); |
| 155 | 148 | } |
| @@ -157,10 +150,8 @@ | ||
| 157 | 150 | /** |
| 158 | 151 | * Get the field property's id |
| 159 | 152 | * |
| 160 | 153 | * @since 2.05 |
| 161 | - * | |
| 162 | - * @return string | |
| 163 | 154 | */ |
| 164 | 155 | public function get_field_id() { |
| 165 | 156 | return $this->get_field_attr( 'id' ); |
| 166 | 157 | } |
| @@ -168,10 +159,8 @@ | ||
| 168 | 159 | /** |
| 169 | 160 | * Get the field property's key |
| 170 | 161 | * |
| 171 | 162 | * @since 2.04 |
| 172 | - * | |
| 173 | - * @return string | |
| 174 | 163 | */ |
| 175 | 164 | public function get_field_key() { |
| 176 | 165 | return $this->get_field_attr( 'field_key' ); |
| 177 | 166 | } |
| @@ -179,10 +168,8 @@ | ||
| 179 | 168 | /** |
| 180 | 169 | * Get the field property's type |
| 181 | 170 | * |
| 182 | 171 | * @since 2.04 |
| 183 | - * | |
| 184 | - * @return string | |
| 185 | 172 | */ |
| 186 | 173 | public function get_field_type() { |
| 187 | 174 | return $this->get_field_attr( 'type' ); |
| 188 | 175 | } |
| @@ -190,10 +177,8 @@ | ||
| 190 | 177 | /** |
| 191 | 178 | * Get the saved_value property |
| 192 | 179 | * |
| 193 | 180 | * @since 2.04 |
| 194 | - * | |
| 195 | - * @return mixed | |
| 196 | 181 | */ |
| 197 | 182 | public function get_saved_value() { |
| 198 | 183 | return $this->saved_value; |
| 199 | 184 | } |
| @@ -201,10 +186,8 @@ | ||
| 201 | 186 | /** |
| 202 | 187 | * Get the displayed_value property |
| 203 | 188 | * |
| 204 | 189 | * @since 2.04 |
| 205 | - * | |
| 206 | - * @return mixed | |
| 207 | 190 | */ |
| 208 | 191 | public function get_displayed_value() { |
| 209 | 192 | if ( $this->displayed_value === 'frm_not_prepared' ) { |
| 210 | 193 | return __( 'The display value has not been prepared. Please use the prepare_display_value() method before calling get_displayed_value().', 'formidable' ); |
| @@ -223,9 +206,10 @@ | ||
| 223 | 206 | * @return void |
| 224 | 207 | */ |
| 225 | 208 | protected function generate_displayed_value_for_field_type( $atts ) { |
| 226 | 209 | if ( ! FrmAppHelper::is_empty_value( $this->displayed_value, '' ) ) { |
| 227 | - $field_obj = FrmFieldFactory::get_field_object( $this->field ); | |
| 210 | + $field_obj = FrmFieldFactory::get_field_object( $this->field ); | |
| 211 | + | |
| 228 | 212 | $this->displayed_value = $field_obj->get_display_value( $this->displayed_value, $atts ); |
| 229 | 213 | } |
| 230 | 214 | } |
| 231 | 215 | |
| @@ -240,14 +224,37 @@ | ||
| 240 | 224 | */ |
| 241 | 225 | protected function filter_displayed_value( $atts ) { |
| 242 | 226 | if ( ! is_object( $this->entry ) || empty( $this->entry->metas ) ) { |
| 243 | 227 | $this->entry = FrmEntry::getOne( $this->entry_id, true ); |
| 244 | - | |
| 245 | 228 | if ( ! is_object( $this->entry ) ) { |
| 246 | 229 | return; |
| 247 | 230 | } |
| 248 | 231 | } |
| 249 | 232 | |
| 233 | + // TODO: maybe change from 'source' to 'run_filters' = 'email' | |
| 234 | + if ( isset( $atts['source'] ) && $atts['source'] === 'entry_formatter' ) { | |
| 235 | + // Deprecated frm_email_value hook | |
| 236 | + $meta = array( | |
| 237 | + 'item_id' => $this->entry->id, | |
| 238 | + 'field_id' => $this->field->id, | |
| 239 | + 'meta_value' => $this->saved_value, | |
| 240 | + 'field_type' => $this->field->type, | |
| 241 | + ); | |
| 242 | + | |
| 243 | + if ( has_filter( 'frm_email_value' ) ) { | |
| 244 | + _deprecated_function( 'The frm_email_value filter', '2.04', 'the frm_display_{fieldtype}_value_custom filter' ); | |
| 245 | + $this->displayed_value = apply_filters( | |
| 246 | + 'frm_email_value', | |
| 247 | + $this->displayed_value, | |
| 248 | + (object) $meta, | |
| 249 | + $this->entry, | |
| 250 | + array( | |
| 251 | + 'field' => $this->field, | |
| 252 | + ) | |
| 253 | + ); | |
| 254 | + } | |
| 255 | + }//end if | |
| 256 | + | |
| 250 | 257 | // frm_display_{fieldtype}_value_custom hook |
| 251 | 258 | $this->displayed_value = apply_filters( |
| 252 | 259 | 'frm_display_' . $this->field->type . '_value_custom', |
| 253 | 260 | $this->displayed_value, |
| @@ -267,18 +274,16 @@ | ||
| 267 | 274 | * |
| 268 | 275 | * @return void |
| 269 | 276 | */ |
| 270 | 277 | protected function clean_saved_value() { |
| 271 | - if ( $this->saved_value === '' ) { | |
| 272 | - return; | |
| 273 | - } | |
| 278 | + if ( $this->saved_value !== '' ) { | |
| 279 | + if ( ! is_array( $this->saved_value ) && ! is_object( $this->saved_value ) ) { | |
| 280 | + $field_type = FrmField::get_field_type( $this->field ); | |
| 281 | + FrmFieldsHelper::prepare_field_value( $this->saved_value, $field_type ); | |
| 282 | + } | |
| 274 | 283 | |
| 275 | - if ( ! is_array( $this->saved_value ) && ! is_object( $this->saved_value ) ) { | |
| 276 | - $field_type = FrmField::get_field_type( $this->field ); | |
| 277 | - FrmFieldsHelper::prepare_field_value( $this->saved_value, $field_type ); | |
| 278 | - } | |
| 279 | - | |
| 280 | - if ( is_array( $this->saved_value ) && empty( $this->saved_value ) ) { | |
| 281 | - $this->saved_value = ''; | |
| 284 | + if ( is_array( $this->saved_value ) && empty( $this->saved_value ) ) { | |
| 285 | + $this->saved_value = ''; | |
| 286 | + } | |
| 282 | 287 | } |
| 283 | 288 | } |
| 284 | 289 | } |