publishableKey() && '' !== $this->secretKey(); } public function renderPage(): void { if ( ! current_user_can( RoleManager::CAP_MANAGE_BILLING ) ) { wp_die( esc_html__( 'You do not have permission to manage billing settings.', 'unsupervised-schedular' ) ); } if ( isset( $_POST['usc_action'] ) && check_admin_referer( 'usc_settings_action' ) ) { $this->save(); } $publishableKey = $this->publishableKey(); $secretKey = $this->secretKey(); $mode = $this->mode(); $currency = $this->currency(); $stripeConfigured = $this->isStripeConfigured(); include USC_PLUGIN_DIR . 'templates/admin/settings.php'; } private function save(): void { // Nonce is verified by the caller (renderPage) before this method runs. // phpcs:disable WordPress.Security.NonceVerification.Missing $mode = sanitize_key( wp_unslash( $_POST['mode'] ?? 'test' ) ); update_option( self::OPT_PUBLISHABLE, sanitize_text_field( wp_unslash( $_POST['publishable_key'] ?? '' ) ) ); update_option( self::OPT_SECRET, sanitize_text_field( wp_unslash( $_POST['secret_key'] ?? '' ) ) ); update_option( self::OPT_MODE, 'live' === $mode ? 'live' : 'test' ); update_option( self::OPT_CURRENCY, strtoupper( sanitize_text_field( wp_unslash( $_POST['currency'] ?? 'CAD' ) ) ) ); // phpcs:enable WordPress.Security.NonceVerification.Missing } }