registry = $registry; } /** * Render the EDD inline settings panel (Reviews + Registration sections). * * Includes the silent-discard toggle and discard-threshold rows under * Product Reviews. * * @since 1.5.0 * * @param array $data Integration data including aggregated sub-settings. * * @return void */ public function render_panel( array $data ): void { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh, Generic.Metrics.CyclomaticComplexity.MaxExceeded $settings_all = $data['settings'] ?? []; $reviews_settings = $settings_all['reviews'] ?? []; $register_settings = $settings_all['registration'] ?? []; ?>

esc_html__( 'Invalid integration for Easy Digital Downloads settings.', 'activelayer-anti-spam-spam-protection-for-forms-comments' ) ], 400 ); return; } // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verified in IntegrationsPage::ajax_save_settings(). $raw_settings = isset( $_POST['settings'] ) && is_array( $_POST['settings'] ) ? wp_unslash( $_POST['settings'] ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized : []; // phpcs:enable WordPress.Security.NonceVerification.Missing $clean_settings = ArrayHelper::sanitize_recursive( $raw_settings ); $reviews_settings = isset( $clean_settings['reviews'] ) && is_array( $clean_settings['reviews'] ) ? $clean_settings['reviews'] : []; $registration_settings = isset( $clean_settings['registration'] ) && is_array( $clean_settings['registration'] ) ? $clean_settings['registration'] : []; $umbrella = $this->resolve_umbrella(); if ( ! $umbrella ) { wp_send_json_error( [ 'message' => esc_html__( 'Easy Digital Downloads integration is not available.', 'activelayer-anti-spam-spam-protection-for-forms-comments' ) ], 400 ); return; } $umbrella->save_settings( $reviews_settings, $registration_settings ); $this->registry->refresh(); wp_send_json_success( array_merge( [ 'message' => esc_html__( 'Settings saved.', 'activelayer-anti-spam-spam-protection-for-forms-comments' ) ], $this->registry->build_onboarding_step_payload() ) ); } /** * Cascade the umbrella's master row toggle to both sub-options. * * Delegates to `EasyDigitalDownloadsIntegration::cascade_enabled()`, which * owns the option-key access for both Reviews and Registration * sub-integrations. * * @since 1.5.0 * * @param bool $enabled New enabled state from the row toggle. * * @throws LogicException When the umbrella integration is not registered — * callers are expected to gate on `wp_ajax` dispatch * for `type=enabled, slug=edd`, which only fires when * the umbrella is present in the registry. * * @return void */ public function cascade_row_toggle( bool $enabled ): void { $umbrella = $this->resolve_umbrella(); if ( ! $umbrella ) { throw new LogicException( 'Easy Digital Downloads umbrella integration missing while cascading row toggle.' ); } $umbrella->cascade_enabled( $enabled ); } /** * Resolve the EDD umbrella integration from the registry. * * @since 1.5.0 * * @return EasyDigitalDownloadsIntegration|null */ private function resolve_umbrella(): ?EasyDigitalDownloadsIntegration { $integration = $this->registry->get_integration( 'edd' ); return $integration instanceof EasyDigitalDownloadsIntegration ? $integration : null; } }