getDefaults()['duration']; $option_value['cookie_hash'] = isset( $option_value['cookie_hash'] ) ? $option_value['cookie_hash'] : $this->getDefaults()['cookie_hash']; ?>

self::UPDATE_COOKIE_ACTION, '_wpnonce' => wp_create_nonce( self::UPDATE_COOKIE_ACTION ) ], admin_url( 'admin-post.php' ) ) ?>
__( 'Cookie lifetime (days)', 'age-verification-screen-for-woocommerce' ), 'id' => Settings::SETTINGS_PREFIX . self::FIELD_ID, 'type' => self::FIELD_TYPE, 'default' => $this->getDefaults(), ); } public function getDefaults() { return array( 'duration' => 30, 'cookie_hash' => md5( site_url() ) ); } public function sanitize( $value ) { $value['duration'] = intval( $value['duration'] ); return $value; } public function updateCookieHash() { $nonce = isset( $_GET['_wpnonce'] ) ? sanitize_text_field( $_GET['_wpnonce'] ) : false; if ( wp_verify_nonce( $nonce, self::UPDATE_COOKIE_ACTION ) ) { $settings = ServiceContainer::getInstance()->getSettings(); $cookie = $settings->get( self::FIELD_ID ); $cookie['cookie_hash'] = wp_generate_password( 10 ); update_option( Settings::SETTINGS_PREFIX . self::FIELD_ID, $cookie ); $this->getContainer()->getAdminNotifier()->flash( __( 'Cookie hash has been successfully updated', 'age-verification-screen-for-woocommerce' ) ); } else { $this->getContainer()->getAdminNotifier()->flash( __( 'Invalid nonce', 'age-verification-screen-for-woocommerce' ), AdminNotifier::ERROR ); } return wp_safe_redirect( wp_get_referer() ); } }