| @@ -8,9 +8,8 @@ | ||
| 8 | 8 | /** |
| 9 | 9 | * "Submitted" entry status. |
| 10 | 10 | * |
| 11 | 11 | * @since 6.4.2 |
| 12 | - * | |
| 13 | 12 | * @var int |
| 14 | 13 | */ |
| 15 | 14 | const SUBMITTED_ENTRY_STATUS = 0; |
| 16 | 15 | |
| @@ -17,21 +16,12 @@ | ||
| 17 | 16 | /** |
| 18 | 17 | * "Draft" entry status. |
| 19 | 18 | * |
| 20 | 19 | * @since 6.4.2 |
| 21 | - * | |
| 22 | 20 | * @var int |
| 23 | 21 | */ |
| 24 | 22 | const DRAFT_ENTRY_STATUS = 1; |
| 25 | 23 | |
| 26 | - /** | |
| 27 | - * @param mixed $fields | |
| 28 | - * @param object|string $form | |
| 29 | - * @param bool $reset | |
| 30 | - * @param array $args | |
| 31 | - * | |
| 32 | - * @return array | |
| 33 | - */ | |
| 34 | 24 | public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
| 35 | 25 | remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
| 36 | 26 | |
| 37 | 27 | $values = array( |
| @@ -40,10 +30,9 @@ | ||
| 40 | 30 | 'item_key' => '', |
| 41 | 31 | ); |
| 42 | 32 | |
| 43 | 33 | $values['fields'] = array(); |
| 44 | - | |
| 45 | - if ( ! $fields ) { | |
| 34 | + if ( empty( $fields ) ) { | |
| 46 | 35 | return apply_filters( 'frm_setup_new_entry', $values ); |
| 47 | 36 | } |
| 48 | 37 | |
| 49 | 38 | foreach ( (array) $fields as $field ) { |
| @@ -48,15 +37,16 @@ | ||
| 48 | 37 | |
| 49 | 38 | foreach ( (array) $fields as $field ) { |
| 50 | 39 | $original_default = $field->default_value; |
| 51 | 40 | self::prepare_field_default_value( $field ); |
| 52 | - $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); | |
| 41 | + $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); | |
| 42 | + | |
| 53 | 43 | $field_array = FrmAppHelper::start_field_array( $field ); |
| 54 | 44 | $field_array['value'] = $new_value; |
| 55 | 45 | $field_array['type'] = apply_filters( 'frm_field_type', $field->type, $field, $new_value ); |
| 56 | - $field_array['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id; | |
| 46 | + $field_array['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; | |
| 57 | 47 | $field_array['reset_value'] = $reset; |
| 58 | - $field_array['in_embed_form'] = $args['in_embed_form'] ?? '0'; | |
| 48 | + $field_array['in_embed_form'] = isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0'; | |
| 59 | 49 | $field_array['original_default'] = $original_default; |
| 60 | 50 | |
| 61 | 51 | FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args ); |
| 62 | 52 | |
| @@ -73,9 +63,8 @@ | ||
| 73 | 63 | } |
| 74 | 64 | }//end foreach |
| 75 | 65 | |
| 76 | 66 | FrmAppHelper::unserialize_or_decode( $form->options ); |
| 77 | - | |
| 78 | 67 | if ( is_array( $form->options ) ) { |
| 79 | 68 | $values = array_merge( $values, $form->options ); |
| 80 | 69 | } |
| 81 | 70 | |
| @@ -90,10 +79,8 @@ | ||
| 90 | 79 | /** |
| 91 | 80 | * @since 2.05 |
| 92 | 81 | * |
| 93 | 82 | * @param object $field |
| 94 | - * | |
| 95 | - * @return void | |
| 96 | 83 | */ |
| 97 | 84 | private static function prepare_field_default_value( &$field ) { |
| 98 | 85 | // If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array. |
| 99 | 86 | $return_array = FrmField::is_field_with_multiple_values( $field ); |
| @@ -114,13 +101,13 @@ | ||
| 114 | 101 | * This function is used when the form is first loaded and on all page turns *for a new entry* |
| 115 | 102 | * |
| 116 | 103 | * @since 2.0.13 |
| 117 | 104 | * |
| 118 | - * @param object $field - this is passed by reference since it is an object. | |
| 119 | - * @param bool $reset | |
| 120 | - * @param array $args | |
| 105 | + * @param object $field - this is passed by reference since it is an object. | |
| 106 | + * @param boolean $reset | |
| 107 | + * @param array $args | |
| 121 | 108 | * |
| 122 | - * @return array|string New value. | |
| 109 | + * @return string|array $new_value | |
| 123 | 110 | */ |
| 124 | 111 | private static function get_field_value_for_new_entry( $field, $reset, $args ) { |
| 125 | 112 | $new_value = $field->default_value; |
| 126 | 113 | |
| @@ -128,9 +115,9 @@ | ||
| 128 | 115 | self::get_posted_value( $field, $new_value, $args ); |
| 129 | 116 | } |
| 130 | 117 | |
| 131 | 118 | if ( ! is_array( $new_value ) ) { |
| 132 | - return str_replace( '"', '"', $new_value ); | |
| 119 | + $new_value = str_replace( '"', '"', $new_value ); | |
| 133 | 120 | } |
| 134 | 121 | |
| 135 | 122 | return $new_value; |
| 136 | 123 | } |
| @@ -142,36 +129,26 @@ | ||
| 142 | 129 | * |
| 143 | 130 | * @param object $field |
| 144 | 131 | * @param array $args |
| 145 | 132 | * |
| 146 | - * @return bool True if a value is posted. | |
| 133 | + * @return boolean $value_is_posted | |
| 147 | 134 | */ |
| 148 | 135 | public static function value_is_posted( $field, $args ) { |
| 149 | 136 | $value_is_posted = false; |
| 150 | - | |
| 151 | - if ( ! $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 152 | - return $value_is_posted; | |
| 153 | - } | |
| 154 | - | |
| 155 | - $repeating = ! empty( $args['repeating'] ); | |
| 156 | - | |
| 157 | - if ( $repeating ) { | |
| 158 | - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 137 | + if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 138 | + $repeating = isset( $args['repeating'] ) && $args['repeating']; | |
| 139 | + if ( $repeating ) { | |
| 140 | + if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 141 | + $value_is_posted = true; | |
| 142 | + } | |
| 143 | + } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 159 | 144 | $value_is_posted = true; |
| 160 | 145 | } |
| 161 | - } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 162 | - $value_is_posted = true; | |
| 163 | 146 | } |
| 164 | 147 | |
| 165 | 148 | return $value_is_posted; |
| 166 | 149 | } |
| 167 | 150 | |
| 168 | - /** | |
| 169 | - * @param array $values | |
| 170 | - * @param object $record | |
| 171 | - * | |
| 172 | - * @return array | |
| 173 | - */ | |
| 174 | 151 | public static function setup_edit_vars( $values, $record ) { |
| 175 | 152 | remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
| 176 | 153 | |
| 177 | 154 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
| @@ -180,22 +157,16 @@ | ||
| 180 | 157 | |
| 181 | 158 | return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); |
| 182 | 159 | } |
| 183 | 160 | |
| 184 | - /** | |
| 185 | - * @param string $message | |
| 186 | - * @param array $atts | |
| 187 | - * | |
| 188 | - * @return string | |
| 189 | - */ | |
| 190 | 161 | public static function replace_default_message( $message, $atts ) { |
| 191 | - if ( ! str_contains( $message, '[default-message' ) && | |
| 192 | - ! str_contains( $message, '[default_message' ) && | |
| 193 | - $message ) { | |
| 162 | + if ( strpos( $message, '[default-message' ) === false && | |
| 163 | + strpos( $message, '[default_message' ) === false && | |
| 164 | + ! empty( $message ) ) { | |
| 194 | 165 | return $message; |
| 195 | 166 | } |
| 196 | 167 | |
| 197 | - if ( ! $message ) { | |
| 168 | + if ( empty( $message ) ) { | |
| 198 | 169 | $message = '[default-message]'; |
| 199 | 170 | } |
| 200 | 171 | |
| 201 | 172 | preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
| @@ -200,12 +171,17 @@ | ||
| 200 | 171 | |
| 201 | 172 | preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
| 202 | 173 | |
| 203 | 174 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 204 | - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); | |
| 205 | - $this_atts = $add_atts ? array_merge( $atts, $add_atts ) : $atts; | |
| 206 | - $default = FrmEntriesController::show_entry_shortcode( $this_atts ); | |
| 175 | + $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); | |
| 176 | + if ( ! empty( $add_atts ) ) { | |
| 177 | + $this_atts = array_merge( $atts, $add_atts ); | |
| 178 | + } else { | |
| 179 | + $this_atts = $atts; | |
| 180 | + } | |
| 207 | 181 | |
| 182 | + $default = FrmEntriesController::show_entry_shortcode( $this_atts ); | |
| 183 | + | |
| 208 | 184 | // Add the default message. |
| 209 | 185 | $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
| 210 | 186 | } |
| 211 | 187 | |
| @@ -215,25 +191,22 @@ | ||
| 215 | 191 | /** |
| 216 | 192 | * @param stdClass $entry |
| 217 | 193 | * @param stdClass $field |
| 218 | 194 | * @param array $atts |
| 219 | - * | |
| 220 | 195 | * @return string |
| 221 | 196 | */ |
| 222 | 197 | public static function prepare_display_value( $entry, $field, $atts ) { |
| 223 | - $field_value = $entry->metas[ $field->id ] ?? false; | |
| 198 | + $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; | |
| 224 | 199 | |
| 225 | 200 | if ( FrmAppHelper::pro_is_installed() ) { |
| 226 | - $empty = ! $field_value; | |
| 201 | + $empty = empty( $field_value ); | |
| 227 | 202 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
| 228 | - | |
| 229 | - if ( $empty && $field_value ) { | |
| 203 | + if ( $empty && ! empty( $field_value ) ) { | |
| 230 | 204 | // We've got an entry id, so switch it to a value. |
| 231 | 205 | $atts['force_id'] = true; |
| 232 | 206 | } |
| 233 | 207 | } |
| 234 | 208 | |
| 235 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 236 | 209 | if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
| 237 | 210 | return self::display_value( $field_value, $field, $atts ); |
| 238 | 211 | } |
| 239 | 212 | |
| @@ -240,19 +213,15 @@ | ||
| 240 | 213 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 241 | 214 | return ''; |
| 242 | 215 | } |
| 243 | 216 | |
| 244 | - if ( is_callable( 'FrmProEntriesHelper::prepare_child_display_value' ) ) { | |
| 245 | - return FrmProEntriesHelper::prepare_child_display_value( $entry, $field, $atts ); | |
| 246 | - } | |
| 247 | - | |
| 248 | - // This is an embedded form. | |
| 249 | - if ( str_starts_with( $atts['embedded_field_id'], 'form' ) ) { | |
| 217 | + // This is an embeded form. | |
| 218 | + if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { | |
| 250 | 219 | // This is a repeating section. |
| 251 | 220 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true ); |
| 252 | 221 | } else { |
| 253 | 222 | // Get all values for this field. |
| 254 | - $child_values = $entry->metas[ $atts['embedded_field_id'] ] ?? false; | |
| 223 | + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; | |
| 255 | 224 | |
| 256 | 225 | if ( $child_values ) { |
| 257 | 226 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
| 258 | 227 | } |
| @@ -257,14 +226,14 @@ | ||
| 257 | 226 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
| 258 | 227 | } |
| 259 | 228 | } |
| 260 | 229 | |
| 230 | + $field_value = array(); | |
| 231 | + | |
| 261 | 232 | if ( empty( $child_entries ) ) { |
| 262 | 233 | return ''; |
| 263 | 234 | } |
| 264 | 235 | |
| 265 | - $field_value = array(); | |
| 266 | - | |
| 267 | 236 | foreach ( $child_entries as $child_entry ) { |
| 268 | 237 | $atts['item_id'] = $child_entry->id; |
| 269 | 238 | $atts['post_id'] = $child_entry->post_id; |
| 270 | 239 | |
| @@ -271,9 +240,9 @@ | ||
| 271 | 240 | // Fet the value for this field -- check for post values as well. |
| 272 | 241 | $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
| 273 | 242 | |
| 274 | 243 | if ( $entry_val || '0' === $entry_val ) { |
| 275 | - // For each entry get display_value. | |
| 244 | + // foreach entry get display_value. | |
| 276 | 245 | $field_value[] = self::display_value( $entry_val, $field, $atts ); |
| 277 | 246 | } |
| 278 | 247 | |
| 279 | 248 | unset( $child_entry ); |
| @@ -279,15 +248,13 @@ | ||
| 279 | 248 | unset( $child_entry ); |
| 280 | 249 | } |
| 281 | 250 | |
| 282 | 251 | $sep = ', '; |
| 283 | - | |
| 284 | - if ( str_contains( implode( ' ', $field_value ), '<img' ) ) { | |
| 252 | + if ( strpos( implode( ' ', (array) $field_value ), '<img' ) !== false ) { | |
| 285 | 253 | $sep = '<br/>'; |
| 286 | 254 | } |
| 255 | + $val = implode( $sep, (array) $field_value ); | |
| 287 | 256 | |
| 288 | - $val = implode( $sep, $field_value ); | |
| 289 | - | |
| 290 | 257 | return FrmAppHelper::kses( $val, 'all' ); |
| 291 | 258 | } |
| 292 | 259 | |
| 293 | 260 | /** |
| @@ -299,8 +266,9 @@ | ||
| 299 | 266 | * |
| 300 | 267 | * @return string |
| 301 | 268 | */ |
| 302 | 269 | public static function display_value( $value, $field, $atts = array() ) { |
| 270 | + | |
| 303 | 271 | $defaults = array( |
| 304 | 272 | 'type' => '', |
| 305 | 273 | 'html' => false, |
| 306 | 274 | 'show_filename' => true, |
| @@ -314,9 +282,9 @@ | ||
| 314 | 282 | ); |
| 315 | 283 | |
| 316 | 284 | $atts = wp_parse_args( $atts, $defaults ); |
| 317 | 285 | |
| 318 | - if ( FrmField::is_image( $field ) || $field->type === 'star' ) { | |
| 286 | + if ( FrmField::is_image( $field ) || $field->type == 'star' ) { | |
| 319 | 287 | $atts['truncate'] = false; |
| 320 | 288 | $atts['html'] = true; |
| 321 | 289 | } |
| 322 | 290 | |
| @@ -321,12 +289,8 @@ | ||
| 321 | 289 | } |
| 322 | 290 | |
| 323 | 291 | $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
| 324 | 292 | |
| 325 | - if ( is_string( $field->field_options ) ) { | |
| 326 | - $field->field_options = array(); | |
| 327 | - } | |
| 328 | - | |
| 329 | 293 | if ( ! isset( $field->field_options['post_field'] ) ) { |
| 330 | 294 | $field->field_options['post_field'] = ''; |
| 331 | 295 | } |
| 332 | 296 | |
| @@ -333,18 +297,17 @@ | ||
| 333 | 297 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 334 | 298 | $field->field_options['custom_field'] = ''; |
| 335 | 299 | } |
| 336 | 300 | |
| 337 | - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] === 'tag' ) ) { | |
| 301 | + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { | |
| 338 | 302 | $atts['pre_truncate'] = $atts['truncate']; |
| 339 | 303 | $atts['truncate'] = true; |
| 340 | - $atts['exclude_cat'] = $field->field_options['exclude_cat'] ?? 0; | |
| 304 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; | |
| 341 | 305 | |
| 342 | 306 | $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); |
| 343 | 307 | $atts['truncate'] = $atts['pre_truncate']; |
| 344 | 308 | } |
| 345 | 309 | |
| 346 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 347 | 310 | if ( $value == '' ) { |
| 348 | 311 | return $value; |
| 349 | 312 | } |
| 350 | 313 | |
| @@ -353,14 +316,13 @@ | ||
| 353 | 316 | |
| 354 | 317 | $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts ); |
| 355 | 318 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
| 356 | 319 | |
| 357 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 358 | 320 | if ( $value == $unfiltered_value ) { |
| 359 | 321 | $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) ); |
| 360 | 322 | } |
| 361 | 323 | |
| 362 | - if ( $atts['truncate'] && $atts['type'] !== 'url' ) { | |
| 324 | + if ( $atts['truncate'] && $atts['type'] != 'url' ) { | |
| 363 | 325 | $value = FrmAppHelper::truncate( $value, 50 ); |
| 364 | 326 | } |
| 365 | 327 | |
| 366 | 328 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
| @@ -369,21 +331,13 @@ | ||
| 369 | 331 | |
| 370 | 332 | return apply_filters( 'frm_display_value', $value, $field, $atts ); |
| 371 | 333 | } |
| 372 | 334 | |
| 373 | - /** | |
| 374 | - * @param object $field | |
| 375 | - * @param mixed $value | |
| 376 | - * @param array $args | |
| 377 | - * | |
| 378 | - * @return void | |
| 379 | - */ | |
| 380 | 335 | public static function set_posted_value( $field, $value, $args ) { |
| 381 | 336 | // If validating a field with "other" opt, set back to prev value now. |
| 382 | - if ( ! empty( $args['other'] ) ) { | |
| 337 | + if ( isset( $args['other'] ) && $args['other'] ) { | |
| 383 | 338 | $value = $args['temp_value']; |
| 384 | 339 | } |
| 385 | - | |
| 386 | 340 | if ( empty( $args['parent_field_id'] ) ) { |
| 387 | 341 | $_POST['item_meta'][ $field->id ] = $value; |
| 388 | 342 | } else { |
| 389 | 343 | self::set_parent_field_posted_value( $field, $value, $args ); |
| @@ -393,18 +347,12 @@ | ||
| 393 | 347 | /** |
| 394 | 348 | * Init arrays if necessary, else we get fatal error. |
| 395 | 349 | * |
| 396 | 350 | * @since 4.01 |
| 397 | - * | |
| 398 | - * @param object $field Field object. | |
| 399 | - * @param mixed $value Value to set. | |
| 400 | - * @param array $args Additional arguments. | |
| 401 | - * | |
| 402 | - * @return void | |
| 403 | 351 | */ |
| 404 | 352 | private static function set_parent_field_posted_value( $field, $value, $args ) { |
| 405 | - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 406 | - if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) || ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 353 | + if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 354 | + if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) || ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 407 | 355 | $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 408 | 356 | } |
| 409 | 357 | } else { |
| 410 | 358 | // All of the section was probably removed. |
| @@ -414,27 +362,15 @@ | ||
| 414 | 362 | |
| 415 | 363 | $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 416 | 364 | } |
| 417 | 365 | |
| 418 | - /** | |
| 419 | - * @param array|int|object|string $field | |
| 420 | - * @param mixed $value | |
| 421 | - * @param array $args | |
| 422 | - * | |
| 423 | - * @return void | |
| 424 | - */ | |
| 425 | 366 | public static function get_posted_value( $field, &$value, $args ) { |
| 426 | 367 | if ( is_array( $field ) ) { |
| 427 | 368 | $field_id = $field['id']; |
| 428 | 369 | $field_obj = FrmFieldFactory::get_field_object( $field['id'] ); |
| 429 | 370 | } elseif ( is_object( $field ) ) { |
| 430 | - $field_id = $field->id; | |
| 431 | - | |
| 432 | - if ( 'hidden' === $field->type && ! empty( $field->field_options['original_type'] ) ) { | |
| 433 | - $field_obj = FrmFieldFactory::get_field_type( $field->field_options['original_type'], $field ); | |
| 434 | - } else { | |
| 435 | - $field_obj = FrmFieldFactory::get_field_object( $field ); | |
| 436 | - } | |
| 371 | + $field_id = $field->id; | |
| 372 | + $field_obj = FrmFieldFactory::get_field_object( $field ); | |
| 437 | 373 | } elseif ( is_numeric( $field ) ) { |
| 438 | 374 | $field_id = $field; |
| 439 | 375 | $field_obj = FrmFieldFactory::get_field_object( $field ); |
| 440 | 376 | } else { |
| @@ -449,21 +385,15 @@ | ||
| 449 | 385 | } |
| 450 | 386 | |
| 451 | 387 | /** |
| 452 | 388 | * @since 4.02.04 |
| 453 | - * @since 6.29 This is public. | |
| 454 | - * | |
| 455 | - * @param int|string $field_id Field ID. | |
| 456 | - * @param array $args Additional arguments. | |
| 457 | - * | |
| 458 | - * @return mixed | |
| 459 | 389 | */ |
| 460 | - public static function get_posted_meta( $field_id, $args ) { | |
| 390 | + private static function get_posted_meta( $field_id, $args ) { | |
| 461 | 391 | if ( empty( $args['parent_field_id'] ) ) { |
| 462 | 392 | // Sanitizing is done next. |
| 463 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 393 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing | |
| 464 | 394 | } else { |
| 465 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 395 | + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing | |
| 466 | 396 | } |
| 467 | 397 | return $value; |
| 468 | 398 | } |
| 469 | 399 | |
| @@ -471,17 +401,14 @@ | ||
| 471 | 401 | * Check if field has an "Other" option and if any other values are posted |
| 472 | 402 | * |
| 473 | 403 | * @since 2.0 |
| 474 | 404 | * |
| 475 | - * @param object $field Field object. | |
| 476 | - * @param array|string $value Field value, passed by reference. | |
| 477 | - * @param array $args Arguments array, passed by reference. | |
| 478 | - * | |
| 479 | - * @return void | |
| 405 | + * @param object $field | |
| 406 | + * @param string|array $value | |
| 407 | + * @param array $args | |
| 480 | 408 | */ |
| 481 | 409 | public static function maybe_set_other_validation( $field, &$value, &$args ) { |
| 482 | 410 | $args['other'] = false; |
| 483 | - | |
| 484 | 411 | if ( ! $value || ! FrmAppHelper::pro_is_installed() ) { |
| 485 | 412 | return; |
| 486 | 413 | } |
| 487 | 414 | |
| @@ -495,22 +422,21 @@ | ||
| 495 | 422 | // Get other value for fields in repeating section. |
| 496 | 423 | self::set_other_repeating_vals( $field, $value, $args ); |
| 497 | 424 | |
| 498 | 425 | // Check if there are any posted "Other" values. |
| 499 | - if ( ! FrmField::is_option_true( $field, 'other' ) || ! isset( $_POST['item_meta']['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 500 | - return; | |
| 501 | - } | |
| 426 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 502 | 427 | |
| 503 | - // Save original value. | |
| 504 | - $args['temp_value'] = $value; | |
| 505 | - $args['other'] = true; | |
| 428 | + // Save original value. | |
| 429 | + $args['temp_value'] = $value; | |
| 430 | + $args['other'] = true; | |
| 506 | 431 | |
| 507 | - // Sanitizing is done next. | |
| 508 | - $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 509 | - FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals ); | |
| 432 | + // Sanitizing is done next. | |
| 433 | + $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing | |
| 434 | + FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals ); | |
| 510 | 435 | |
| 511 | - // Set the validation value now | |
| 512 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); | |
| 436 | + // Set the validation value now | |
| 437 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); | |
| 438 | + } | |
| 513 | 439 | } |
| 514 | 440 | |
| 515 | 441 | /** |
| 516 | 442 | * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
| @@ -516,13 +442,11 @@ | ||
| 516 | 442 | * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
| 517 | 443 | * |
| 518 | 444 | * @since 2.0 |
| 519 | 445 | * |
| 520 | - * @param object $field Field object. | |
| 521 | - * @param array|string $value Field value, passed by reference. | |
| 522 | - * @param array $args Arguments array, passed by reference. | |
| 523 | - * | |
| 524 | - * @return void | |
| 446 | + * @param object $field | |
| 447 | + * @param string|array $value | |
| 448 | + * @param array $args | |
| 525 | 449 | */ |
| 526 | 450 | public static function set_other_repeating_vals( $field, &$value, &$args ) { |
| 527 | 451 | if ( ! $args['parent_field_id'] ) { |
| 528 | 452 | return; |
| @@ -528,20 +452,19 @@ | ||
| 528 | 452 | return; |
| 529 | 453 | } |
| 530 | 454 | |
| 531 | 455 | // Check if there are any other posted "other" values for this field. |
| 532 | - if ( ! FrmField::is_option_true( $field, 'other' ) || ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 533 | - return; | |
| 534 | - } | |
| 456 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 457 | + // Save original value | |
| 458 | + $args['temp_value'] = $value; | |
| 459 | + $args['other'] = true; | |
| 535 | 460 | |
| 536 | - // Save original value | |
| 537 | - $args['temp_value'] = $value; | |
| 538 | - $args['other'] = true; | |
| 539 | - $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 540 | - FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals ); | |
| 461 | + $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing | |
| 462 | + FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals ); | |
| 541 | 463 | |
| 542 | - // Set the validation value now. | |
| 543 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); | |
| 464 | + // Set the validation value now. | |
| 465 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); | |
| 466 | + } | |
| 544 | 467 | } |
| 545 | 468 | |
| 546 | 469 | /** |
| 547 | 470 | * Modify value used for validation |
| @@ -551,17 +474,15 @@ | ||
| 551 | 474 | * Needs to accommodate for times when other opt is selected, but no other free text is entered |
| 552 | 475 | * |
| 553 | 476 | * @since 2.0 |
| 554 | 477 | * |
| 555 | - * @param array|string $value | |
| 556 | - * @param array|string $other_vals (usually of posted values). | |
| 478 | + * @param string|array $value | |
| 479 | + * @param string|array $other_vals (usually of posted values). | |
| 557 | 480 | * @param object $field |
| 558 | 481 | * @param array $args |
| 559 | - * | |
| 560 | - * @return void | |
| 561 | 482 | */ |
| 562 | 483 | public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
| 563 | - // Checkboxes. | |
| 484 | + // Checkboxes and multi-select dropdowns. | |
| 564 | 485 | if ( is_array( $value ) && $field->type === 'checkbox' ) { |
| 565 | 486 | // Combine "Other" values with checked values. "Other" values will override checked box values. |
| 566 | 487 | foreach ( $other_vals as $k => $v ) { |
| 567 | 488 | if ( isset( $value[ $k ] ) && trim( $v ) === '' ) { |
| @@ -570,43 +491,39 @@ | ||
| 570 | 491 | break; |
| 571 | 492 | } |
| 572 | 493 | } |
| 573 | 494 | |
| 574 | - if ( is_array( $value ) && $value ) { | |
| 495 | + if ( is_array( $value ) && ! empty( $value ) ) { | |
| 575 | 496 | $value = array_merge( $value, $other_vals ); |
| 576 | 497 | } |
| 498 | + } else { | |
| 499 | + // Radio and dropdowns. | |
| 500 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); | |
| 501 | + $other_key = reset( $other_key ); | |
| 577 | 502 | |
| 578 | - return; | |
| 579 | - } | |
| 503 | + // Multi-select dropdown. | |
| 504 | + if ( is_array( $value ) ) { | |
| 505 | + $o_key = array_search( $field->options[ $other_key ], $value ); | |
| 580 | 506 | |
| 581 | - // Radio and dropdowns. | |
| 582 | - $other_key = array_filter( array_keys( $field->options ), 'is_string' ); | |
| 583 | - $other_key = reset( $other_key ); | |
| 507 | + if ( $o_key !== false ) { | |
| 508 | + // Modify the original value so other key will be preserved. | |
| 509 | + $value[ $other_key ] = $value[ $o_key ]; | |
| 584 | 510 | |
| 585 | - // Multi-select dropdown. | |
| 586 | - if ( is_array( $value ) ) { | |
| 587 | - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 588 | - $o_key = array_search( $field->options[ $other_key ], $value ); | |
| 511 | + // By default, the array keys will be numeric for multi-select dropdowns. | |
| 512 | + // If going backwards and forwards between pages, the array key will match the other key. | |
| 513 | + if ( $o_key !== $other_key ) { | |
| 514 | + unset( $value[ $o_key ] ); | |
| 515 | + } | |
| 589 | 516 | |
| 590 | - if ( $o_key !== false ) { | |
| 591 | - // Modify the original value so other key will be preserved. | |
| 592 | - $value[ $other_key ] = $value[ $o_key ]; | |
| 593 | - | |
| 594 | - // By default, the array keys will be numeric for multi-select dropdowns. | |
| 595 | - // If going backwards and forwards between pages, the array key will match the other key. | |
| 596 | - if ( $o_key !== $other_key ) { | |
| 597 | - unset( $value[ $o_key ] ); | |
| 517 | + $args['temp_value'] = $value; | |
| 518 | + $value[ $other_key ] = reset( $other_vals ); | |
| 519 | + if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) { | |
| 520 | + unset( $value[ $other_key ] ); | |
| 521 | + } | |
| 598 | 522 | } |
| 599 | - | |
| 600 | - $args['temp_value'] = $value; | |
| 601 | - $value[ $other_key ] = reset( $other_vals ); | |
| 602 | - | |
| 603 | - if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) { | |
| 604 | - unset( $value[ $other_key ] ); | |
| 605 | - } | |
| 606 | - } | |
| 607 | - } elseif ( $field->options[ $other_key ] == $value ) { // phpcs:ignore Universal.Operators.StrictComparisons | |
| 608 | - $value = $other_vals; | |
| 523 | + } elseif ( $field->options[ $other_key ] == $value ) { | |
| 524 | + $value = $other_vals; | |
| 525 | + }//end if | |
| 609 | 526 | }//end if |
| 610 | 527 | } |
| 611 | 528 | |
| 612 | 529 | /** |
| @@ -612,16 +529,14 @@ | ||
| 612 | 529 | /** |
| 613 | 530 | * Add submitted values to a string for spam checking. |
| 614 | 531 | * |
| 615 | 532 | * @param array $values |
| 616 | - * | |
| 617 | 533 | * @return string |
| 618 | 534 | */ |
| 619 | 535 | public static function entry_array_to_string( $values ) { |
| 620 | 536 | $content = ''; |
| 621 | - | |
| 622 | 537 | foreach ( $values['item_meta'] as $val ) { |
| 623 | - if ( $content !== '' ) { | |
| 538 | + if ( $content != '' ) { | |
| 624 | 539 | $content .= "\n\n"; |
| 625 | 540 | } |
| 626 | 541 | |
| 627 | 542 | if ( is_array( $val ) ) { |
| @@ -645,9 +560,9 @@ | ||
| 645 | 560 | * @return string |
| 646 | 561 | */ |
| 647 | 562 | public static function get_browser( $u_agent ) { |
| 648 | 563 | $bname = __( 'Unknown', 'formidable' ); |
| 649 | - $platform = $bname; | |
| 564 | + $platform = __( 'Unknown', 'formidable' ); | |
| 650 | 565 | $ub = ''; |
| 651 | 566 | |
| 652 | 567 | // Get the operating system |
| 653 | 568 | if ( preg_match( '/windows|win32/i', $u_agent ) ) { |
| @@ -667,15 +582,15 @@ | ||
| 667 | 582 | 'Netscape' => 'Netscape', |
| 668 | 583 | 'Firefox' => 'Mozilla Firefox', |
| 669 | 584 | ); |
| 670 | 585 | |
| 671 | - // Next get the name of the useragent yes separately and for good reason. | |
| 672 | - if ( str_contains( $u_agent, 'MSIE' ) && ! str_contains( $u_agent, 'Opera' ) ) { | |
| 586 | + // Next get the name of the useragent yes seperately and for good reason | |
| 587 | + if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) { | |
| 673 | 588 | $bname = 'Internet Explorer'; |
| 674 | 589 | $ub = 'MSIE'; |
| 675 | 590 | } else { |
| 676 | 591 | foreach ( $agent_options as $agent_key => $agent_name ) { |
| 677 | - if ( str_contains( $u_agent, $agent_key ) ) { | |
| 592 | + if ( strpos( $u_agent, $agent_key ) !== false ) { | |
| 678 | 593 | $bname = $agent_name; |
| 679 | 594 | $ub = $agent_key; |
| 680 | 595 | break; |
| 681 | 596 | } |
| @@ -681,21 +596,25 @@ | ||
| 681 | 596 | } |
| 682 | 597 | } |
| 683 | 598 | } |
| 684 | 599 | |
| 685 | - // Finally get the correct version number | |
| 600 | + // finally get the correct version number | |
| 686 | 601 | $known = array( 'Version', $ub, 'other' ); |
| 687 | - $pattern = '#(?<browser>' . implode( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; | |
| 602 | + $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; | |
| 688 | 603 | // Get the matching numbers. |
| 689 | 604 | preg_match_all( $pattern, $u_agent, $matches ); |
| 690 | 605 | |
| 691 | - // See how many we have | |
| 606 | + // see how many we have | |
| 692 | 607 | $i = count( $matches['browser'] ); |
| 693 | 608 | |
| 694 | 609 | if ( $i > 1 ) { |
| 695 | 610 | // We will have two since we are not using 'other' argument yet |
| 696 | - // See if version is before or after the name. | |
| 697 | - $version = strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ? $matches['version'][0] : $matches['version'][1]; | |
| 611 | + // see if version is before or after the name. | |
| 612 | + if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) { | |
| 613 | + $version = $matches['version'][0]; | |
| 614 | + } else { | |
| 615 | + $version = $matches['version'][1]; | |
| 616 | + } | |
| 698 | 617 | } elseif ( $i === 1 ) { |
| 699 | 618 | $version = $matches['version'][0]; |
| 700 | 619 | } else { |
| 701 | 620 | $version = ''; |
| @@ -700,10 +619,10 @@ | ||
| 700 | 619 | } else { |
| 701 | 620 | $version = ''; |
| 702 | 621 | } |
| 703 | 622 | |
| 704 | - // Check if we have a number | |
| 705 | - if ( $version === '' ) { | |
| 623 | + // check if we have a number | |
| 624 | + if ( $version == '' ) { | |
| 706 | 625 | $version = '?'; |
| 707 | 626 | } |
| 708 | 627 | |
| 709 | 628 | return $bname . ' ' . $version . ' / ' . $platform; |
| @@ -710,19 +629,14 @@ | ||
| 710 | 629 | } |
| 711 | 630 | |
| 712 | 631 | /** |
| 713 | 632 | * @since 3.0 |
| 714 | - * | |
| 715 | - * @param array $atts Action dropdown attributes. | |
| 716 | - * | |
| 717 | - * @return void | |
| 718 | 633 | */ |
| 719 | 634 | public static function actions_dropdown( $atts ) { |
| 720 | - $id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); | |
| 635 | + $id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); | |
| 721 | 636 | $links = self::get_action_links( $id, $atts['entry'] ); |
| 722 | 637 | |
| 723 | 638 | foreach ( $links as $link ) { |
| 724 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 725 | 639 | ?> |
| 726 | 640 | <div class="misc-pub-section"> |
| 727 | 641 | <a href="<?php echo esc_url( $link['url'] ); ?>" |
| 728 | 642 | <?php |
| @@ -730,13 +644,11 @@ | ||
| 730 | 644 | foreach ( $link['data'] as $data => $value ) { |
| 731 | 645 | echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" '; |
| 732 | 646 | } |
| 733 | 647 | } |
| 734 | - | |
| 735 | 648 | if ( isset( $link['class'] ) ) { |
| 736 | 649 | echo 'class="' . esc_attr( $link['class'] ) . '" '; |
| 737 | 650 | } |
| 738 | - | |
| 739 | 651 | if ( isset( $link['id'] ) ) { |
| 740 | 652 | echo 'id="' . esc_attr( $link['id'] ) . '" '; |
| 741 | 653 | } |
| 742 | 654 | ?> |
| @@ -745,29 +657,23 @@ | ||
| 745 | 657 | <span class="frm_link_label"><?php echo esc_html( $link['label'] ); ?></span> |
| 746 | 658 | </a> |
| 747 | 659 | </div> |
| 748 | 660 | <?php |
| 749 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 750 | 661 | }//end foreach |
| 751 | 662 | } |
| 752 | 663 | |
| 753 | 664 | /** |
| 754 | 665 | * @since 3.0 |
| 755 | - * | |
| 756 | - * @param int $id Entry ID. | |
| 757 | - * @param array|object $entry Entry object. | |
| 758 | - * | |
| 759 | - * @return array | |
| 760 | 666 | */ |
| 761 | 667 | private static function get_action_links( $id, $entry ) { |
| 762 | 668 | $page = FrmAppHelper::get_param( 'frm_action' ); |
| 763 | 669 | $actions = array(); |
| 764 | 670 | |
| 765 | - if ( $page !== 'show' ) { | |
| 671 | + if ( $page != 'show' ) { | |
| 766 | 672 | $actions['frm_view'] = array( |
| 767 | 673 | 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=show&id=' . $id . '&form=' . $entry->form_id ), |
| 768 | 674 | 'label' => __( 'View Entry', 'formidable' ), |
| 769 | - 'icon' => 'frmfont frm_save_icon', | |
| 675 | + 'icon' => 'frm_icon_font frm_save_icon', | |
| 770 | 676 | ); |
| 771 | 677 | } |
| 772 | 678 | |
| 773 | 679 | if ( current_user_can( 'frm_delete_entries' ) ) { |
| @@ -773,17 +679,16 @@ | ||
| 773 | 679 | if ( current_user_can( 'frm_delete_entries' ) ) { |
| 774 | 680 | $actions['frm_delete'] = array( |
| 775 | 681 | 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ), |
| 776 | 682 | 'label' => __( 'Delete Entry', 'formidable' ), |
| 777 | - 'icon' => 'frmfont frm_delete_icon', | |
| 683 | + 'icon' => 'frm_icon_font frm_delete_icon', | |
| 778 | 684 | 'data' => array( |
| 779 | - 'frmverify' => __( 'Permanently delete this entry?', 'formidable' ), | |
| 780 | - 'frmverify-btn' => 'frm-button-red', | |
| 685 | + 'frmverify' => __( 'Delete this form entry?', 'formidable' ), | |
| 781 | 686 | ), |
| 782 | 687 | ); |
| 783 | 688 | } |
| 784 | 689 | |
| 785 | - if ( $page === 'show' ) { | |
| 690 | + if ( $page == 'show' ) { | |
| 786 | 691 | $actions['frm_print'] = array( |
| 787 | 692 | 'url' => '#', |
| 788 | 693 | 'label' => __( 'Print Entry', 'formidable' ), |
| 789 | 694 | 'data' => array( |
| @@ -788,9 +693,9 @@ | ||
| 788 | 693 | 'label' => __( 'Print Entry', 'formidable' ), |
| 789 | 694 | 'data' => array( |
| 790 | 695 | 'frmprint' => '1', |
| 791 | 696 | ), |
| 792 | - 'icon' => 'frmfont frm_printer_icon', | |
| 697 | + 'icon' => 'frm_icon_font frm_printer_icon', | |
| 793 | 698 | ); |
| 794 | 699 | } |
| 795 | 700 | |
| 796 | 701 | $actions['frm_resend'] = array( |
| @@ -801,18 +706,18 @@ | ||
| 801 | 706 | 'upgrade' => __( 'Resend Emails', 'formidable' ), |
| 802 | 707 | 'medium' => 'resend-email', |
| 803 | 708 | 'content' => 'entry', |
| 804 | 709 | ), |
| 805 | - 'icon' => 'frmfont frm_email_icon', | |
| 710 | + 'icon' => 'frm_icon_font frm_email_icon', | |
| 806 | 711 | ); |
| 807 | 712 | |
| 808 | - if ( ! function_exists( 'frm_pdfs_autoloader' ) ) { | |
| 713 | + if ( ! function_exists( 'frm_pdfs_autoloader' ) && FrmAppHelper::show_new_feature( 'pdfs' ) ) { | |
| 809 | 714 | $actions['frm_download_pdf'] = array( |
| 810 | 715 | 'url' => '#', |
| 811 | 716 | 'label' => __( 'Download as PDF', 'formidable' ), |
| 812 | 717 | 'class' => 'frm_noallow', |
| 813 | 718 | 'data' => self::get_pdfs_upgrade_link_data( 'download-pdf-entry' ), |
| 814 | - 'icon' => 'frmfont frm_download_icon', | |
| 719 | + 'icon' => 'frm_icon_font frm_download_icon', | |
| 815 | 720 | ); |
| 816 | 721 | } |
| 817 | 722 | |
| 818 | 723 | $actions['frm_edit'] = array( |
| @@ -823,9 +728,9 @@ | ||
| 823 | 728 | 'upgrade' => __( 'Entry edits', 'formidable' ), |
| 824 | 729 | 'medium' => 'edit-entries', |
| 825 | 730 | 'content' => 'entry', |
| 826 | 731 | ), |
| 827 | - 'icon' => 'frmfont frm_pencil_icon', | |
| 732 | + 'icon' => 'frm_icon_font frm_pencil_icon', | |
| 828 | 733 | ); |
| 829 | 734 | |
| 830 | 735 | return apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) ); |
| 831 | 736 | } |
| @@ -833,9 +738,8 @@ | ||
| 833 | 738 | /** |
| 834 | 739 | * Gets data attributes for PDFs addon upgrade link. |
| 835 | 740 | * |
| 836 | 741 | * @param string $medium The source of the upgrade link used for analytics data. |
| 837 | - * | |
| 838 | 742 | * @return array |
| 839 | 743 | */ |
| 840 | 744 | private static function get_pdfs_upgrade_link_data( $medium = 'pdfs' ) { |
| 841 | 745 | $data = array( |
| @@ -845,9 +749,8 @@ | ||
| 845 | 749 | 'medium' => $medium, |
| 846 | 750 | ); |
| 847 | 751 | |
| 848 | 752 | $upgrading = FrmAddonsController::install_link( 'pdfs' ); |
| 849 | - | |
| 850 | 753 | if ( isset( $upgrading['url'] ) ) { |
| 851 | 754 | $data['oneclick'] = json_encode( $upgrading ); |
| 852 | 755 | } else { |
| 853 | 756 | $data['requires'] = FrmAddonsController::get_addon_required_plan( 28136428 ); |
| @@ -858,10 +761,9 @@ | ||
| 858 | 761 | |
| 859 | 762 | /** |
| 860 | 763 | * @since 5.0.15 |
| 861 | 764 | * |
| 862 | - * @param int|string $entry_id | |
| 863 | - * | |
| 765 | + * @param string|int $entry_id | |
| 864 | 766 | * @return void |
| 865 | 767 | */ |
| 866 | 768 | public static function maybe_render_captcha_score( $entry_id ) { |
| 867 | 769 | $query = array( |
| @@ -868,20 +770,17 @@ | ||
| 868 | 770 | 'item_id' => (int) $entry_id, |
| 869 | 771 | 'field_id' => 0, |
| 870 | 772 | ); |
| 871 | 773 | $metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true ); |
| 872 | - | |
| 873 | 774 | foreach ( $metas_without_a_field as $meta ) { |
| 874 | - if ( empty( $meta->meta_value['captcha_score'] ) ) { | |
| 875 | - continue; | |
| 775 | + if ( ! empty( $meta->meta_value['captcha_score'] ) ) { | |
| 776 | + echo '<div class="misc-pub-section">'; | |
| 777 | + FrmAppHelper::icon_by_class( 'frm_icon_font frm_shield_check_icon', array( 'aria-hidden' => 'true' ) ); | |
| 778 | + echo ' ' . esc_html__( 'reCAPTCHA Score', 'formidable' ) . ': '; | |
| 779 | + echo '<b>' . esc_html( $meta->meta_value['captcha_score'] ) . '</b>'; | |
| 780 | + echo '</div>'; | |
| 781 | + return; | |
| 876 | 782 | } |
| 877 | - | |
| 878 | - echo '<div class="misc-pub-section">'; | |
| 879 | - FrmAppHelper::icon_by_class( 'frmfont frm_shield_check_icon', array( 'aria-hidden' => 'true' ) ); | |
| 880 | - echo ' ' . esc_html__( 'reCAPTCHA Score', 'formidable' ) . ': '; | |
| 881 | - echo '<b>' . esc_html( $meta->meta_value['captcha_score'] ) . '</b>'; | |
| 882 | - echo '</div>'; | |
| 883 | - return; | |
| 884 | 783 | } |
| 885 | 784 | } |
| 886 | 785 | |
| 887 | 786 | /** |
| @@ -893,13 +792,15 @@ | ||
| 893 | 792 | * |
| 894 | 793 | * @return int |
| 895 | 794 | */ |
| 896 | 795 | public static function get_entry_status( $status ) { |
| 897 | - if ( array_key_exists( $status, self::get_entry_statuses() ) ) { | |
| 796 | + $statuses = self::get_entry_statuses(); | |
| 797 | + | |
| 798 | + if ( array_key_exists( $status, $statuses ) ) { | |
| 898 | 799 | return $status; |
| 899 | 800 | } |
| 900 | 801 | |
| 901 | - if ( ! $status ) { | |
| 802 | + if ( empty( $status ) ) { | |
| 902 | 803 | // If the status is empty, let's default to 0. |
| 903 | 804 | return self::SUBMITTED_ENTRY_STATUS; |
| 904 | 805 | } |
| 905 | 806 | |
| @@ -916,9 +817,11 @@ | ||
| 916 | 817 | * |
| 917 | 818 | * @return string |
| 918 | 819 | */ |
| 919 | 820 | public static function get_entry_status_label( $status ) { |
| 920 | - return self::get_entry_statuses()[ self::get_entry_status( $status ) ]; | |
| 821 | + $statuses = self::get_entry_statuses(); | |
| 822 | + | |
| 823 | + return $statuses[ self::get_entry_status( $status ) ]; | |
| 921 | 824 | } |
| 922 | 825 | |
| 923 | 826 | /** |
| 924 | 827 | * Get all entry statuses. |
| @@ -928,8 +831,9 @@ | ||
| 928 | 831 | * |
| 929 | 832 | * @return array<string> |
| 930 | 833 | */ |
| 931 | 834 | public static function get_entry_statuses() { |
| 835 | + | |
| 932 | 836 | $default_entry_statuses = array( |
| 933 | 837 | self::SUBMITTED_ENTRY_STATUS => __( 'Submitted', 'formidable' ), |
| 934 | 838 | self::DRAFT_ENTRY_STATUS => __( 'Draft', 'formidable' ), |
| 935 | 839 | ); |
| @@ -950,35 +854,10 @@ | ||
| 950 | 854 | _doing_it_wrong( __METHOD__, esc_html__( 'Entry status must be return in array format.', 'formidable' ), '6.5' ); |
| 951 | 855 | $extended_entry_status = array(); |
| 952 | 856 | } |
| 953 | 857 | |
| 954 | - return array_replace( $default_entry_statuses, $extended_entry_status ); | |
| 858 | + $existing_entry_statuses = array_replace( $default_entry_statuses, $extended_entry_status ); | |
| 859 | + | |
| 860 | + return $existing_entry_statuses; | |
| 955 | 861 | } |
| 956 | 862 | |
| 957 | - /** | |
| 958 | - * @since 6.17 | |
| 959 | - * | |
| 960 | - * @return int | |
| 961 | - */ | |
| 962 | - public static function get_visible_unread_inbox_count() { | |
| 963 | - if ( ! in_array( FrmAppHelper::get_menu_name(), array( 'Formidable', 'Forms' ), true ) ) { | |
| 964 | - return 0; | |
| 965 | - } | |
| 966 | - | |
| 967 | - $inbox = new FrmInbox(); | |
| 968 | - $inbox_count = count( $inbox->unread() ); | |
| 969 | - | |
| 970 | - if ( ! $inbox_count ) { | |
| 971 | - return 0; | |
| 972 | - } | |
| 973 | - | |
| 974 | - if ( is_callable( 'FrmProSettingsController::inbox_badge' ) ) { | |
| 975 | - $inbox_count = FrmProSettingsController::inbox_badge( $inbox_count ); | |
| 976 | - | |
| 977 | - if ( ! $inbox_count ) { | |
| 978 | - return 0; | |
| 979 | - } | |
| 980 | - } | |
| 981 | - | |
| 982 | - return $inbox_count; | |
| 983 | - } | |
| 984 | 863 | } |