| @@ -47,13 +47,16 @@ | ||
| 47 | 47 | protected function include_form_builder_file() { |
| 48 | 48 | return FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/field-user-id.php'; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | + /** | |
| 52 | + * @param array $args | |
| 53 | + */ | |
| 51 | 54 | public function prepare_field_html( $args ) { |
| 52 | 55 | $args = $this->fill_display_field_values( $args ); |
| 53 | 56 | $value = $this->get_field_value( $args ); |
| 54 | 57 | |
| 55 | - echo '<input type="hidden" name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" value="' . esc_attr( $value ) . '" data-frmval="' . esc_attr( $value ) . '"/>' . "\n"; | |
| 58 | + echo '<input type="hidden" name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" value="' . esc_attr( $value ) . '" data-frmval="' . esc_attr( $value ) . '"/>' . "\n"; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 56 | 59 | } |
| 57 | 60 | |
| 58 | 61 | /** |
| 59 | 62 | * @since 4.03.06 |
| @@ -63,16 +66,22 @@ | ||
| 63 | 66 | * @return int|string |
| 64 | 67 | */ |
| 65 | 68 | protected function get_field_value( $args ) { |
| 66 | 69 | $user_ID = get_current_user_id(); |
| 67 | - $user_ID = ( $user_ID ? $user_ID : '' ); | |
| 68 | - $posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][ $this->field['id'] ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 69 | - $action = ( $args['action'] ?? $args['form_action'] ?? '' ); | |
| 70 | + $user_ID = $user_ID ? $user_ID : ''; | |
| 71 | + $posted_value = FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][ $this->field['id'] ] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 72 | + $action = $args['action'] ?? $args['form_action'] ?? ''; | |
| 70 | 73 | $updating = $action === 'update'; |
| 71 | 74 | return is_numeric( $this->field['value'] ) || $posted_value || $updating ? $this->field['value'] : $user_ID; |
| 72 | 75 | } |
| 73 | 76 | |
| 77 | + /** | |
| 78 | + * @param array $args | |
| 79 | + * | |
| 80 | + * @return array | |
| 81 | + */ | |
| 74 | 82 | public function validate( $args ) { |
| 83 | + // phpcs:ignore Universal.Operators.StrictComparisons | |
| 75 | 84 | if ( '' == $args['value'] ) { |
| 76 | 85 | return array(); |
| 77 | 86 | } |
| 78 | 87 | |
| @@ -95,9 +104,8 @@ | ||
| 95 | 104 | * @return array|string A string is returned, but the return signature should match FrmFieldType. |
| 96 | 105 | */ |
| 97 | 106 | protected function prepare_display_value( $value, $atts ) { |
| 98 | 107 | $user_info = $this->prepare_user_info_attribute( $atts ); |
| 99 | - | |
| 100 | 108 | return FrmFieldsHelper::get_user_display_name( $value, $user_info, $atts ); |
| 101 | 109 | } |
| 102 | 110 | |
| 103 | 111 | /** |
| @@ -112,18 +120,12 @@ | ||
| 112 | 120 | * @return string |
| 113 | 121 | */ |
| 114 | 122 | private function prepare_user_info_attribute( $atts ) { |
| 115 | 123 | if ( isset( $atts['show'] ) ) { |
| 116 | - if ( $atts['show'] === 'id' ) { | |
| 117 | - $user_info = 'ID'; | |
| 118 | - } else { | |
| 119 | - $user_info = $atts['show']; | |
| 120 | - } | |
| 121 | - } else { | |
| 122 | - $user_info = apply_filters( 'frm_user_id_display', 'display_name' ); | |
| 124 | + return $atts['show'] === 'id' ? 'ID' : $atts['show']; | |
| 123 | 125 | } |
| 124 | 126 | |
| 125 | - return $user_info; | |
| 127 | + return apply_filters( 'frm_user_id_display', 'display_name' ); | |
| 126 | 128 | } |
| 127 | 129 | |
| 128 | 130 | /** |
| 129 | 131 | * @param string $value |