| @@ -13,9 +13,9 @@ | ||
| 13 | 13 | */ |
| 14 | 14 | class FrmFormState { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * @var FrmFormState | |
| 17 | + * @var FrmFormState|null | |
| 18 | 18 | */ |
| 19 | 19 | private static $instance; |
| 20 | 20 | |
| 21 | 21 | /** |
| @@ -46,9 +46,9 @@ | ||
| 46 | 46 | /** |
| 47 | 47 | * @return bool true if just initialized. |
| 48 | 48 | */ |
| 49 | 49 | private static function maybe_initialize() { |
| 50 | - if ( empty( self::$instance ) ) { | |
| 50 | + if ( ! self::$instance ) { | |
| 51 | 51 | self::$instance = new self(); |
| 52 | 52 | return true; |
| 53 | 53 | } |
| 54 | 54 | return false; |
| @@ -102,9 +102,9 @@ | ||
| 102 | 102 | // This way we can also avoid duplicate state fields if Pro isn't up to date. |
| 103 | 103 | return; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ( empty( self::$instance ) && ! self::get_state_from_request() ) { | |
| 106 | + if ( ! self::$instance && ! self::get_state_from_request() ) { | |
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $honeypot_field_id = self::$instance->get( 'honeypot_field_id', 0 ); |
| @@ -168,10 +168,9 @@ | ||
| 168 | 168 | if ( ! $this->state && ! self::get_state_from_request() ) { |
| 169 | 169 | return; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $state_string = $this->get_state_string(); | |
| 173 | - echo '<input name="frm_state" type="hidden" value="' . esc_attr( $state_string ) . '" />'; | |
| 172 | + echo '<input name="frm_state" type="hidden" value="' . esc_attr( $this->get_state_string() ) . '" />'; | |
| 174 | 173 | } |
| 175 | 174 | |
| 176 | 175 | /** |
| 177 | 176 | * @return string |
| @@ -180,11 +179,10 @@ | ||
| 180 | 179 | if ( ! self::open_ssl_is_installed() ) { |
| 181 | 180 | return ''; |
| 182 | 181 | } |
| 183 | 182 | |
| 184 | - $secret = self::get_encryption_secret(); | |
| 185 | - $compressed_state = $this->compressed_state(); | |
| 186 | - $json_encoded = json_encode( $compressed_state ); | |
| 183 | + $secret = self::get_encryption_secret(); | |
| 184 | + $json_encoded = json_encode( $this->compressed_state() ); | |
| 187 | 185 | return openssl_encrypt( $json_encoded, 'AES-128-ECB', $secret ); |
| 188 | 186 | } |
| 189 | 187 | |
| 190 | 188 | /** |
| @@ -259,9 +257,9 @@ | ||
| 259 | 257 | } |
| 260 | 258 | |
| 261 | 259 | // We don't have a secret, so let's generate one. |
| 262 | 260 | $secret_key = is_callable( 'sodium_crypto_secretbox_keygen' ) ? sodium_crypto_secretbox_keygen() : wp_generate_password( 32, true, true ); |
| 263 | - update_option( 'frm_form_state_key', base64_encode( $secret_key ), 'no' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode | |
| 261 | + update_option( 'frm_form_state_key', base64_encode( $secret_key ), false ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode | |
| 264 | 262 | |
| 265 | 263 | return $secret_key; |
| 266 | 264 | } |
| 267 | 265 | } |