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/drakkar_site_dev/wp-content/plugins/formidable/classes/models/FrmFieldOption.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	die( 'You are not allowed to call this page directly.' );
}

/**
 * @since 2.03.05
 */
class FrmFieldOption {

	/**
	 * @var int|string
	 *
	 * @since 2.03.05
	 */
	protected $option_key;

	/**
	 * @var array|string
	 *
	 * @since 2.03.05
	 */
	protected $option;

	/**
	 * @var string
	 * @since 2.03.05
	 */
	protected $saved_value = '';

	/**
	 * @var string
	 * @since 2.03.05
	 */
	protected $option_label = '';

	public function __construct( $option_key, $option, $args = array() ) {
		$this->option_key = $option_key;
		$this->option     = $option;
		$this->set_option_label();
		$this->set_saved_value();
	}

	/**
	 * Set the option label
	 *
	 * @since 2.03.05
	 *
	 * @return void
	 */
	private function set_option_label() {
		if ( is_array( $this->option ) ) {
			$this->option_label = ( isset( $this->option['label'] ) ? $this->option['label'] : reset( $this->option ) );
		} else {
			$this->option_label = $this->option;
		}
	}

	/**
	 * Set the saved value
	 *
	 * @since 2.03.05
	 *
	 * @return void
	 */
	protected function set_saved_value() {
		$this->saved_value = $this->option_label;
	}

	/**
	 * Print a single option
	 *
	 * @since 2.03.05
	 *
	 * @param string $selected_value
	 * @param int    $truncate
	 *
	 * @return void
	 */
	public function print_single_option( $selected_value, $truncate ) {
		if ( '' !== $this->saved_value ) {
			echo '<option value="' . esc_attr( $this->saved_value ) . '"';
			selected( esc_attr( $selected_value ), esc_attr( $this->saved_value ) );
			// TODO: add hook that can add attributes to option text
			echo '>';
			echo esc_html( FrmAppHelper::truncate( $this->option_label, $truncate ) ) . '</option>';
		}
	}
}