HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux vm8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: afleverb (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //var/www/winter_site/wp-content/plugins/wpforms-lite/src/Admin/Payments/Views/Overview/Helpers.php
<?php

namespace WPForms\Admin\Payments\Views\Overview;

use WPForms\Db\Payments\ValueValidator;

/**
 * Helper methods for the Overview page.
 *
 * @since 1.8.2
 */
class Helpers {

	/**
	 * Get subscription description.
	 *
	 * @since 1.8.2
	 *
	 * @param string $payment_id Payment id.
	 * @param string $amount     Payment amount.
	 *
	 * @return string
	 */
	public static function get_subscription_description( $payment_id, $amount ) {

		// Get the subscription period for the payment.
		$period    = wpforms()->get( 'payment_meta' )->get_single( $payment_id, 'subscription_period' );
		$intervals = ValueValidator::get_allowed_subscription_intervals();

		// If the subscription period is not set or not allowed, return the amount only.
		if ( ! isset( $intervals[ $period ] ) ) {
			return $amount;
		}

		// Use "/" as a separator between the amount and the subscription period.
		return $amount . ' / ' . $intervals[ $period ];
	}

	/**
	 * Return a placeholder text "N/A" when there is no actual data to display.
	 *
	 * @since 1.8.2
	 *
	 * @param string $with_wrapper Wrap the text within a span tag for styling purposes. Default: true.
	 *
	 * @return string
	 */
	public static function get_placeholder_na_text( $with_wrapper = true ) {

		$text = __( 'N/A', 'wpforms-lite' );

		// Check if the text should be wrapped within a span tag.
		if ( $with_wrapper ) {
			return sprintf( '<span class="payment-placeholder-text-none">%s</span>', $text );
		}

		return $text;
	}
}