| @@ -9,77 +9,72 @@ | ||
| 9 | 9 | public static $transient_size = 200; |
| 10 | 10 | |
| 11 | 11 | public static function field_selection() { |
| 12 | 12 | $fields = array( |
| 13 | - 'text' => array( | |
| 13 | + 'text' => array( | |
| 14 | 14 | 'name' => __( 'Text', 'formidable' ), |
| 15 | 15 | 'icon' => 'frm_icon_font frm_text2_icon', |
| 16 | 16 | ), |
| 17 | - 'textarea' => array( | |
| 17 | + 'textarea' => array( | |
| 18 | 18 | 'name' => __( 'Paragraph', 'formidable' ), |
| 19 | 19 | 'icon' => 'frm_icon_font frm_paragraph_icon', |
| 20 | 20 | ), |
| 21 | - 'checkbox' => array( | |
| 21 | + 'checkbox' => array( | |
| 22 | 22 | 'name' => __( 'Checkboxes', 'formidable' ), |
| 23 | 23 | 'icon' => 'frm_icon_font frm_check_square_icon', |
| 24 | 24 | ), |
| 25 | - 'radio' => array( | |
| 25 | + 'radio' => array( | |
| 26 | 26 | 'name' => __( 'Radio Buttons', 'formidable' ), |
| 27 | 27 | 'icon' => 'frm_icon_font frm_radio_checked_icon', |
| 28 | 28 | ), |
| 29 | - 'select' => array( | |
| 29 | + 'select' => array( | |
| 30 | 30 | 'name' => __( 'Dropdown', 'formidable' ), |
| 31 | - 'icon' => 'frm_icon_font frm_dropdown_icon', | |
| 31 | + 'icon' => 'frm_icon_font frm_caret_square_down_icon', | |
| 32 | 32 | ), |
| 33 | - 'email' => array( | |
| 33 | + 'email' => array( | |
| 34 | 34 | 'name' => __( 'Email', 'formidable' ), |
| 35 | - 'icon' => 'frm_icon_font frm_email2_icon', | |
| 35 | + 'icon' => 'frm_icon_font frm_email_icon', | |
| 36 | 36 | ), |
| 37 | - 'url' => array( | |
| 37 | + 'url' => array( | |
| 38 | 38 | 'name' => __( 'Website/URL', 'formidable' ), |
| 39 | - 'icon' => 'frm_icon_font frm_link2_icon', | |
| 39 | + 'icon' => 'frm_icon_font frm_link_icon', | |
| 40 | 40 | ), |
| 41 | - 'number' => array( | |
| 41 | + 'number' => array( | |
| 42 | 42 | 'name' => __( 'Number', 'formidable' ), |
| 43 | 43 | 'icon' => 'frm_icon_font frm_hashtag_icon', |
| 44 | 44 | ), |
| 45 | - 'name' => array( | |
| 45 | + 'name' => array( | |
| 46 | 46 | 'name' => __( 'Name', 'formidable' ), |
| 47 | 47 | 'icon' => 'frm_icon_font frm_user_name_icon', |
| 48 | 48 | ), |
| 49 | - 'phone' => array( | |
| 49 | + 'phone' => array( | |
| 50 | 50 | 'name' => __( 'Phone', 'formidable' ), |
| 51 | 51 | 'icon' => 'frm_icon_font frm_phone_icon', |
| 52 | 52 | ), |
| 53 | - 'html' => array( | |
| 53 | + 'html' => array( | |
| 54 | 54 | 'name' => __( 'HTML', 'formidable' ), |
| 55 | - 'icon' => 'frm_icon_font frm_code2_icon', | |
| 55 | + 'icon' => 'frm_icon_font frm_code_icon', | |
| 56 | 56 | ), |
| 57 | - 'hidden' => array( | |
| 57 | + 'hidden' => array( | |
| 58 | 58 | 'name' => __( 'Hidden', 'formidable' ), |
| 59 | - 'icon' => 'frm_icon_font frm_eye_slash2_icon', | |
| 59 | + 'icon' => 'frm_icon_font frm_eye_slash_icon', | |
| 60 | 60 | ), |
| 61 | - 'user_id' => array( | |
| 61 | + 'user_id' => array( | |
| 62 | 62 | 'name' => __( 'User ID', 'formidable' ), |
| 63 | - 'icon' => 'frm_icon_font frm_user2_icon', | |
| 63 | + 'icon' => 'frm_icon_font frm_user_icon', | |
| 64 | 64 | ), |
| 65 | - 'captcha' => array( | |
| 65 | + 'captcha' => array( | |
| 66 | 66 | 'name' => self::get_captcha_field_name(), |
| 67 | - 'icon' => 'frm_icon_font frm_shield_check2_icon', | |
| 67 | + 'icon' => 'frm_icon_font frm_shield_check_icon', | |
| 68 | 68 | ), |
| 69 | - 'credit_card' => array( | |
| 69 | + 'credit_card' => array( | |
| 70 | 70 | 'name' => __( 'Payment', 'formidable' ), |
| 71 | - 'icon' => 'frm_icon_font frm_credit_card2_icon', | |
| 71 | + 'icon' => 'frm_icon_font frm_credit_card_icon', | |
| 72 | 72 | ), |
| 73 | - FrmSubmitHelper::FIELD_TYPE => array( | |
| 73 | + FrmSubmitHelper::FIELD_TYPE => array( | |
| 74 | 74 | 'name' => __( 'Submit', 'formidable' ), |
| 75 | 75 | 'hide' => true, |
| 76 | 76 | ), |
| 77 | - FrmFieldGdprHelper::FIELD_TYPE => array( | |
| 78 | - 'name' => __( 'GDPR', 'formidable' ), | |
| 79 | - 'icon' => 'frm_icon_font frm-gdpr-icon', | |
| 80 | - 'hide' => FrmFieldGdprHelper::hide_gdpr_field(), | |
| 81 | - ), | |
| 82 | 77 | ); |
| 83 | 78 | |
| 84 | 79 | /** |
| 85 | 80 | * @param array $fields |
| @@ -100,9 +95,9 @@ | ||
| 100 | 95 | $images_url = FrmAppHelper::plugin_url() . '/images/'; |
| 101 | 96 | $fields = array( |
| 102 | 97 | 'file' => array( |
| 103 | 98 | 'name' => __( 'File Upload', 'formidable' ), |
| 104 | - 'icon' => 'frm_icon_font frm_upload3_icon', | |
| 99 | + 'icon' => 'frm_icon_font frm_upload_icon', | |
| 105 | 100 | 'message' => __( 'Add file uploads to save time and cut down on back-and-forth. Upgrade to Pro to get Upload fields and more.', 'formidable' ), |
| 106 | 101 | ), |
| 107 | 102 | 'ranking' => array(), |
| 108 | 103 | 'rte' => array( |
| @@ -110,9 +105,9 @@ | ||
| 110 | 105 | 'icon' => 'frm_icon_font frm_align_right_icon', |
| 111 | 106 | ), |
| 112 | 107 | 'date' => array( |
| 113 | 108 | 'name' => __( 'Date', 'formidable' ), |
| 114 | - 'icon' => 'frm_icon_font frm_calendar2_icon', | |
| 109 | + 'icon' => 'frm_icon_font frm_calendar_icon', | |
| 115 | 110 | ), |
| 116 | 111 | 'time' => array( |
| 117 | 112 | 'name' => __( 'Time', 'formidable' ), |
| 118 | 113 | 'icon' => 'frm_icon_font frm_clock_icon', |
| @@ -123,9 +118,9 @@ | ||
| 123 | 118 | 'message' => esc_html__( 'Add a set of radio buttons with whatever range you choose.', 'formidable' ) . '<img src="' . esc_url( $images_url ) . 'scale_field.png" alt="' . esc_attr__( 'Scale Field', 'formidable' ) . '" />', |
| 124 | 119 | ), |
| 125 | 120 | 'star' => array( |
| 126 | 121 | 'name' => __( 'Star Rating', 'formidable' ), |
| 127 | - 'icon' => 'frm_icon_font frm_star2_icon', | |
| 122 | + 'icon' => 'frm_icon_font frm_star_icon', | |
| 128 | 123 | ), |
| 129 | 124 | 'range' => array( |
| 130 | 125 | 'name' => __( 'Slider', 'formidable' ), |
| 131 | 126 | 'icon' => 'frm_icon_font frm_code_commit_icon', |
| @@ -135,9 +130,9 @@ | ||
| 135 | 130 | 'icon' => 'frm_icon_font frm_toggle_on_icon', |
| 136 | 131 | ), |
| 137 | 132 | 'data' => array( |
| 138 | 133 | 'name' => __( 'Dynamic', 'formidable' ), |
| 139 | - 'icon' => 'frm_icon_font frm_dynamic_icon', | |
| 134 | + 'icon' => 'frm_icon_font frm_sitemap_icon', | |
| 140 | 135 | 'message' => __( 'Create relationships between multiple forms. You can link a member to a team, a rating to a product, a comment to a submission, and much more.', 'formidable' ), |
| 141 | 136 | ), |
| 142 | 137 | 'lookup' => array( |
| 143 | 138 | 'name' => __( 'Lookup', 'formidable' ), |
| @@ -145,9 +140,9 @@ | ||
| 145 | 140 | 'message' => esc_html__( 'Filter the options in the next field and automatically add values to other fields. Upgrade to Pro to get Lookup fields and more.', 'formidable' ) . ' <img src="' . esc_url( $images_url ) . 'look-up_year-make-model.gif" alt="' . esc_attr__( 'cascading lookup fields', 'formidable' ) . '" />', |
| 146 | 141 | ), |
| 147 | 142 | 'divider|repeat' => array( |
| 148 | 143 | 'name' => __( 'Repeater', 'formidable' ), |
| 149 | - 'icon' => 'frm_icon_font frm_refresh_icon', | |
| 144 | + 'icon' => 'frm_icon_font frm_repeater_icon', | |
| 150 | 145 | 'message' => esc_html__( 'Allow your visitors to add new sets of fields while filling out forms. Increase conversions while saving building time and server resources.', 'formidable' ) . ' <img src="' . esc_url( $images_url ) . 'repeatable-section_frontend.gif" alt="' . esc_attr__( 'Dynamically Add Form Fields with repeatable sections', 'formidable' ) . '" />', |
| 151 | 146 | ), |
| 152 | 147 | 'end_divider' => array( |
| 153 | 148 | 'name' => __( 'Section Buttons', 'formidable' ), |
| @@ -163,9 +158,9 @@ | ||
| 163 | 158 | 'message' => __( 'Get multi-paged forms with progress bars. Did you know you can upgrade to PRO to unlock multi-step forms with more awesome features?', 'formidable' ), |
| 164 | 159 | ), |
| 165 | 160 | 'form' => array( |
| 166 | 161 | 'name' => __( 'Embed Form', 'formidable' ), |
| 167 | - 'icon' => 'frm_icon_font frm_file_text2_icon', | |
| 162 | + 'icon' => 'frm_icon_font frm_file_text_icon', | |
| 168 | 163 | ), |
| 169 | 164 | 'likert' => array( |
| 170 | 165 | 'name' => __( 'Likert Scale', 'formidable' ), |
| 171 | 166 | 'icon' => 'frm_icon_font frm_likert_scale frm_show_upgrade', |
| @@ -177,13 +172,13 @@ | ||
| 177 | 172 | 'addon' => 'surveys', |
| 178 | 173 | ), |
| 179 | 174 | 'password' => array( |
| 180 | 175 | 'name' => __( 'Password', 'formidable' ), |
| 181 | - 'icon' => 'frm_icon_font frm_lock_closed2_icon', | |
| 176 | + 'icon' => 'frm_icon_font frm_lock_open_icon', | |
| 182 | 177 | ), |
| 183 | 178 | 'tag' => array( |
| 184 | 179 | 'name' => __( 'Tags', 'formidable' ), |
| 185 | - 'icon' => 'frm_icon_font frm_price_tags2_icon', | |
| 180 | + 'icon' => 'frm_icon_font frm_price_tags_icon', | |
| 186 | 181 | ), |
| 187 | 182 | // This is no longer a Pro field, but without this here, Pro triggers "undefined index" notices. |
| 188 | 183 | // Right now it leaves a gap. Maybe we can skip anything without a name or something. |
| 189 | 184 | 'credit_card' => array( |
| @@ -191,13 +186,13 @@ | ||
| 191 | 186 | 'icon' => '', |
| 192 | 187 | ), |
| 193 | 188 | 'address' => array( |
| 194 | 189 | 'name' => __( 'Address', 'formidable' ), |
| 195 | - 'icon' => 'frm_icon_font frm_location2_icon', | |
| 190 | + 'icon' => 'frm_icon_font frm_location_icon', | |
| 196 | 191 | ), |
| 197 | 192 | 'summary' => array( |
| 198 | 193 | 'name' => __( 'Summary', 'formidable' ), |
| 199 | - 'icon' => 'frm_icon_font frm_file_text3_icon', | |
| 194 | + 'icon' => 'frm_icon_font frm_file_text_icon', | |
| 200 | 195 | 'message' => __( 'Allow visitors to review their responses before a form is submitted. Upgrade to Pro to get Summary fields and more.', 'formidable' ), |
| 201 | 196 | ), |
| 202 | 197 | 'signature' => array( |
| 203 | 198 | 'name' => __( 'Signature', 'formidable' ), |
| @@ -205,15 +200,15 @@ | ||
| 205 | 200 | 'addon' => 'signature', |
| 206 | 201 | ), |
| 207 | 202 | 'ai' => array( |
| 208 | 203 | 'name' => __( 'AI', 'formidable' ), |
| 209 | - 'icon' => 'frm_icon_font frm-ai-icon frm_show_upgrade', | |
| 204 | + 'icon' => 'frm_icon_font frm_eye_icon frm_show_upgrade', | |
| 210 | 205 | 'addon' => 'ai', |
| 211 | 206 | 'message' => __( 'Streamline workflows and reclaim valuable time with the power of AI. You can effortlessly respond to your visitors in real-time with ChatGPT as your automated assistant. Upgrade to Pro and unlock AI-powered fields.', 'formidable' ), |
| 212 | 207 | ), |
| 213 | 208 | 'ssa-appointment' => array( |
| 214 | 209 | 'name' => __( 'Appointment', 'formidable' ), |
| 215 | - 'icon' => 'frm_icon_font frm_schedule_icon frm_show_upgrade', | |
| 210 | + 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade', | |
| 216 | 211 | 'require' => 'Simply Schedule Appointments', |
| 217 | 212 | 'message' => sprintf( |
| 218 | 213 | /* translators: %1$s: Link opening HTML, %2$s: Link tag closing */ |
| 219 | 214 | esc_html__( 'Appointment fields are an integration with %1$sSimply Schedule Appointments%2$s. Get started now to schedule appointments directly from your forms.', 'formidable' ), |
| @@ -223,9 +218,9 @@ | ||
| 223 | 218 | 'link' => 'https://simplyscheduleappointments.com/meet/formidable/', |
| 224 | 219 | ), |
| 225 | 220 | 'product' => array( |
| 226 | 221 | 'name' => __( 'Product', 'formidable' ), |
| 227 | - 'icon' => 'frm_icon_font frm_product2_icon', | |
| 222 | + 'icon' => 'frm_icon_font frm_product_icon', | |
| 228 | 223 | 'section' => 'pricing', |
| 229 | 224 | ), |
| 230 | 225 | 'quantity' => array( |
| 231 | 226 | 'name' => __( 'Quantity', 'formidable' ), |
| @@ -233,9 +228,9 @@ | ||
| 233 | 228 | 'section' => 'pricing', |
| 234 | 229 | ), |
| 235 | 230 | 'total' => array( |
| 236 | 231 | 'name' => __( 'Total', 'formidable' ), |
| 237 | - 'icon' => 'frm_icon_font frm_total2_icon', | |
| 232 | + 'icon' => 'frm_icon_font frm_total_icon', | |
| 238 | 233 | 'section' => 'pricing', |
| 239 | 234 | ), |
| 240 | 235 | ); |
| 241 | 236 | |
| @@ -376,17 +371,15 @@ | ||
| 376 | 371 | public static function create( $values, $return = true ) { |
| 377 | 372 | global $wpdb, $frm_duplicate_ids; |
| 378 | 373 | |
| 379 | 374 | $new_values = array(); |
| 380 | - $key = $values['field_key'] ?? $values['name']; | |
| 375 | + $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name']; | |
| 381 | 376 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 382 | 377 | |
| 383 | 378 | $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) ); |
| 384 | 379 | |
| 385 | 380 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
| 386 | - if ( isset( $values[ $col ] ) ) { | |
| 387 | - $new_values[ $col ] = $values[ $col ]; | |
| 388 | - } | |
| 381 | + $new_values[ $col ] = $values[ $col ]; | |
| 389 | 382 | } |
| 390 | 383 | |
| 391 | 384 | $new_values['options'] = self::maybe_filter_options( $values['options'] ); |
| 392 | 385 | $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null; |
| @@ -810,14 +803,14 @@ | ||
| 810 | 803 | $field = FrmDb::check_cache( $id, 'frm_field' ); |
| 811 | 804 | if ( $field ) { |
| 812 | 805 | $type = $field->{$col}; |
| 813 | 806 | } else { |
| 814 | - if ( is_numeric( $id ) ) { | |
| 815 | - $where = array( 'id' => $id ); | |
| 816 | - } else { | |
| 817 | - $where = array( 'field_key' => $id ); | |
| 818 | - } | |
| 819 | - $type = FrmDb::get_var( 'frm_fields', $where, $col ); | |
| 807 | + $where = array( | |
| 808 | + 'or' => 1, | |
| 809 | + 'id' => $id, | |
| 810 | + 'field_key' => $id, | |
| 811 | + ); | |
| 812 | + $type = FrmDb::get_var( 'frm_fields', $where, $col ); | |
| 820 | 813 | } |
| 821 | 814 | |
| 822 | 815 | return $type; |
| 823 | 816 | } |
| @@ -1010,9 +1003,9 @@ | ||
| 1010 | 1003 | } |
| 1011 | 1004 | |
| 1012 | 1005 | $limit = FrmDb::esc_limit( $limit ); |
| 1013 | 1006 | |
| 1014 | - $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi JOIN {$form_table_name} fr ON fi.form_id=fr.id"; | |
| 1007 | + $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; | |
| 1015 | 1008 | $query_type = $limit === ' LIMIT 1' || $limit == 1 ? 'row' : 'results'; |
| 1016 | 1009 | |
| 1017 | 1010 | if ( is_array( $where ) ) { |
| 1018 | 1011 | $args = array( |
| @@ -1018,9 +1011,9 @@ | ||
| 1018 | 1011 | $args = array( |
| 1019 | 1012 | 'order_by' => $order_by, |
| 1020 | 1013 | 'limit' => $limit, |
| 1021 | 1014 | ); |
| 1022 | - $results = FrmDb::get_var( $table_name . ' fi JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', $args, '', $query_type ); | |
| 1015 | + $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', $args, '', $query_type ); | |
| 1023 | 1016 | } else { |
| 1024 | 1017 | // if the query is not an array, then it has already been prepared |
| 1025 | 1018 | $query .= FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
| 1026 | 1019 | |
| @@ -1090,16 +1083,11 @@ | ||
| 1090 | 1083 | FrmAppHelper::unserialize_or_decode( $results->options ); |
| 1091 | 1084 | |
| 1092 | 1085 | // Allow a single box to be checked for the default value. |
| 1093 | 1086 | $before = $results->default_value; |
| 1094 | - | |
| 1095 | - $field_object = FrmFieldFactory::get_field_type( $results->type ); | |
| 1096 | - | |
| 1097 | - if ( $field_object->should_unserialize_value() ) { | |
| 1098 | - FrmAppHelper::unserialize_or_decode( $results->default_value ); | |
| 1099 | - if ( $before === $results->default_value && is_string( $before ) && strpos( $before, '["' ) === 0 ) { | |
| 1100 | - $results->default_value = FrmAppHelper::maybe_json_decode( $results->default_value ); | |
| 1101 | - } | |
| 1087 | + FrmAppHelper::unserialize_or_decode( $results->default_value ); | |
| 1088 | + if ( $before === $results->default_value && ! is_array( $before ) && strpos( $before, '["' ) === 0 ) { | |
| 1089 | + $results->default_value = FrmAppHelper::maybe_json_decode( $results->default_value ); | |
| 1102 | 1090 | } |
| 1103 | 1091 | } |
| 1104 | 1092 | |
| 1105 | 1093 | /** |
| @@ -1149,9 +1137,9 @@ | ||
| 1149 | 1137 | $set = set_transient( $name, $field, 60 * 60 * 6 ); |
| 1150 | 1138 | if ( ! $set ) { |
| 1151 | 1139 | // the transient didn't save |
| 1152 | 1140 | if ( $name != $base_name ) { |
| 1153 | - // if the first saved an others fail, this will show an incomplete form | |
| 1141 | + // if the first saved an others fail, this will show an incmoplete form | |
| 1154 | 1142 | self::delete_form_transient( $form_id ); |
| 1155 | 1143 | } |
| 1156 | 1144 | |
| 1157 | 1145 | return; |
| @@ -1383,9 +1371,9 @@ | ||
| 1383 | 1371 | * @param string $option |
| 1384 | 1372 | * @return mixed |
| 1385 | 1373 | */ |
| 1386 | 1374 | public static function get_option_in_object( $field, $option ) { |
| 1387 | - return $field->field_options[ $option ] ?? ''; | |
| 1375 | + return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : ''; | |
| 1388 | 1376 | } |
| 1389 | 1377 | |
| 1390 | 1378 | /** |
| 1391 | 1379 | * @since 2.0.09 |