| @@ -136,25 +136,29 @@ | ||
| 136 | 136 | 'formStyling' => [ |
| 137 | 137 | 'type' => 'object', |
| 138 | 138 | 'description' => __( 'Form styling settings including colors and spacing.', 'sureforms' ), |
| 139 | 139 | 'properties' => [ |
| 140 | - 'primaryColor' => [ | |
| 140 | + 'primaryColor' => [ | |
| 141 | 141 | 'type' => 'string', |
| 142 | 142 | 'description' => __( 'Primary/accent color as hex (e.g. #111C44).', 'sureforms' ), |
| 143 | 143 | ], |
| 144 | - 'textColor' => [ | |
| 144 | + 'textColor' => [ | |
| 145 | 145 | 'type' => 'string', |
| 146 | 146 | 'description' => __( 'Text color as hex (e.g. #1E1E1E).', 'sureforms' ), |
| 147 | 147 | ], |
| 148 | - 'textColorOnPrimary' => [ | |
| 148 | + 'textColorOnPrimary' => [ | |
| 149 | 149 | 'type' => 'string', |
| 150 | 150 | 'description' => __( 'Text color on primary backgrounds as hex (e.g. #FFFFFF).', 'sureforms' ), |
| 151 | 151 | ], |
| 152 | - 'fieldSpacing' => [ | |
| 152 | + 'fieldSpacing' => [ | |
| 153 | 153 | 'type' => 'string', |
| 154 | 154 | 'description' => __( 'Spacing between fields.', 'sureforms' ), |
| 155 | 155 | 'enum' => [ 'small', 'medium', 'large' ], |
| 156 | 156 | ], |
| 157 | + 'disableDefaultStyles' => [ | |
| 158 | + 'type' => 'boolean', | |
| 159 | + 'description' => __( 'When true, SureForms does not enqueue its default frontend styles for this form, so the active theme styling applies instead.', 'sureforms' ), | |
| 160 | + ], | |
| 157 | 161 | ], |
| 158 | 162 | ], |
| 159 | 163 | 'emailNotification' => [ |
| 160 | 164 | 'type' => 'object', |
| @@ -315,8 +319,12 @@ | ||
| 315 | 319 | ); |
| 316 | 320 | |
| 317 | 321 | $post_content = Field_Mapping::generate_gutenberg_fields_from_questions( $request ); |
| 318 | 322 | |
| 323 | + if ( is_wp_error( $post_content ) ) { | |
| 324 | + return $post_content; | |
| 325 | + } | |
| 326 | + | |
| 319 | 327 | if ( empty( $post_content ) ) { |
| 320 | 328 | return new \WP_Error( |
| 321 | 329 | 'srfm_field_mapping_failed', |
| 322 | 330 | __( 'Failed to generate form fields from the provided data.', 'sureforms' ), |
| @@ -326,9 +334,16 @@ | ||
| 326 | 334 | |
| 327 | 335 | // Get default post meta. |
| 328 | 336 | $post_metas = Create_New_Form::get_default_meta_keys(); |
| 329 | 337 | |
| 330 | - // Add serialized meta defaults for metadata overrides. | |
| 338 | + // Pull complex-meta defaults from the registered schemas so created | |
| 339 | + // forms are identical to hand-created ones. Storing empty arrays/strings | |
| 340 | + // would override the register_post_meta 'default' values (WordPress only | |
| 341 | + // uses those defaults when no value is stored at all), causing confirmation | |
| 342 | + // messages, email notifications, styling, and restriction settings to be | |
| 343 | + // blank for any form created through this code path. | |
| 344 | + $registered = get_registered_meta_keys( 'post', SRFM_FORMS_POST_TYPE ); | |
| 345 | + | |
| 331 | 346 | $post_metas['_srfm_instant_form_settings'] = [ |
| 332 | 347 | 'bg_type' => 'color', |
| 333 | 348 | 'bg_color' => '#ffffff', |
| 334 | 349 | 'bg_image' => '', |
| @@ -340,13 +355,13 @@ | ||
| 340 | 355 | 'form_container_width' => 620, |
| 341 | 356 | 'single_page_form_title' => true, |
| 342 | 357 | 'use_banner_as_page_background' => false, |
| 343 | 358 | ]; |
| 344 | - $post_metas['_srfm_form_confirmation'] = []; | |
| 345 | - $post_metas['_srfm_compliance'] = []; | |
| 346 | - $post_metas['_srfm_forms_styling'] = []; | |
| 347 | - $post_metas['_srfm_email_notification'] = []; | |
| 348 | - $post_metas['_srfm_form_restriction'] = ''; | |
| 359 | + $post_metas['_srfm_form_confirmation'] = $registered['_srfm_form_confirmation']['default'] ?? []; | |
| 360 | + $post_metas['_srfm_compliance'] = $registered['_srfm_compliance']['default'] ?? []; | |
| 361 | + $post_metas['_srfm_forms_styling'] = $registered['_srfm_forms_styling']['default'] ?? []; | |
| 362 | + $post_metas['_srfm_email_notification'] = $registered['_srfm_email_notification']['default'] ?? []; | |
| 363 | + $post_metas['_srfm_form_restriction'] = $registered['_srfm_form_restriction']['default'] ?? ''; | |
| 349 | 364 | $post_metas['_srfm_form_custom_css'] = ''; |
| 350 | 365 | |
| 351 | 366 | // Apply metadata overrides from input. |
| 352 | 367 | $post_metas = $this->apply_metadata_overrides( $post_metas, $meta_data ); |