| @@ -74,9 +74,12 @@ | ||
| 74 | 74 | return self::$instance->get( $key, $default ); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function get( $key, $default ) { |
| 78 | - return $this->state[ $key ] ?? $default; | |
| 78 | + if ( isset( $this->state[ $key ] ) ) { | |
| 79 | + return $this->state[ $key ]; | |
| 80 | + } | |
| 81 | + return $default; | |
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | /** |
| 82 | 85 | * Render a basic version of the state field from Pro. |
| @@ -92,16 +95,14 @@ | ||
| 92 | 95 | // This way we can also avoid duplicate state fields if Pro isn't up to date. |
| 93 | 96 | return; |
| 94 | 97 | } |
| 95 | 98 | |
| 96 | - if ( empty( self::$instance ) && ! self::get_state_from_request() ) { | |
| 99 | + if ( empty( $form->options['ajax_submit'] ) ) { | |
| 100 | + // This is only required for AJAX submit. | |
| 97 | 101 | return; |
| 98 | 102 | } |
| 99 | 103 | |
| 100 | - $honeypot_field_id = self::$instance->get( 'honeypot_field_id', 0 ); | |
| 101 | - | |
| 102 | - if ( empty( $form->options['ajax_submit'] ) && ! $honeypot_field_id ) { | |
| 103 | - // This is only required for AJAX submit, or when the honeypot field is on the page. | |
| 104 | + if ( empty( self::$instance ) && ! self::get_state_from_request() ) { | |
| 104 | 105 | return; |
| 105 | 106 | } |
| 106 | 107 | |
| 107 | 108 | $state_title = ! empty( self::$instance->state['title'] ) ? 1 : 0; |
| @@ -108,10 +109,10 @@ | ||
| 108 | 109 | $state_description = ! empty( self::$instance->state['description'] ) ? 1 : 0; |
| 109 | 110 | $settings_title = ! empty( $form->options['show_title'] ) ? 1 : 0; |
| 110 | 111 | $settings_description = ! empty( $form->options['show_description'] ) ? 1 : 0; |
| 111 | 112 | |
| 112 | - if ( $state_title === $settings_title && $state_description === $settings_description && ! $honeypot_field_id ) { | |
| 113 | - // Avoid state field if it matches form settings and there is no honeypot. | |
| 113 | + if ( $state_title === $settings_title && $state_description === $settings_description ) { | |
| 114 | + // Avoid state field if it matches form settings. | |
| 114 | 115 | return; |
| 115 | 116 | } |
| 116 | 117 | |
| 117 | 118 | self::$instance->render_state_field(); |
| @@ -216,10 +217,8 @@ | ||
| 216 | 217 | case 'd': |
| 217 | 218 | return 'description'; |
| 218 | 219 | case 't': |
| 219 | 220 | return 'title'; |
| 220 | - case 'h': | |
| 221 | - return 'honeypot_field_id'; | |
| 222 | 221 | } |
| 223 | 222 | return $key; |
| 224 | 223 | } |
| 225 | 224 | |