PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 3.06.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v3.06.06
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / models / FrmFieldOption.php

FrmFieldOption.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 3.06.06, at classes/models/FrmFieldOption.php

81 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @since 2.03.05
5 */
6 class FrmFieldOption {
7
8 /**
9 * @var string|int
10 *
11 * @since 2.03.05
12 */
13 protected $option_key;
14
15 /**
16 * @var string|array
17 *
18 * @since 2.03.05
19 */
20 protected $option;
21
22 /**
23 * @var string
24 * @since 2.03.05
25 */
26 protected $saved_value = '';
27
28 /**
29 * @var string
30 * @since 2.03.05
31 */
32 protected $option_label = '';
33
34 public function __construct( $option_key, $option, $args = array() ) {
35 $this->option_key = $option_key;
36 $this->option = $option;
37 $this->set_option_label();
38 $this->set_saved_value();
39 }
40
41 /**
42 * Set the option label
43 *
44 * @since 2.03.05
45 */
46 private function set_option_label() {
47 if ( is_array( $this->option ) ) {
48 $this->option_label = ( isset( $this->option['label'] ) ? $this->option['label'] : reset( $this->option ) );
49 } else {
50 $this->option_label = $this->option;
51 }
52 }
53
54 /**
55 * Set the saved value
56 *
57 * @since 2.03.05
58 */
59 protected function set_saved_value() {
60 $this->saved_value = $this->option_label;
61 }
62
63 /**
64 * Print a single option
65 *
66 * @since 2.03.05
67 *
68 * @param string $selected_value
69 * @param int $truncate
70 */
71 public function print_single_option( $selected_value, $truncate ) {
72 if ( '' !== $this->saved_value ) {
73 echo '<option value="' . esc_attr( $this->saved_value ) . '"';
74 selected( esc_attr( $selected_value ), esc_attr( $this->saved_value ) );
75 // TODO: add hook that can add attributes to option text
76 echo '>';
77 echo esc_html( FrmAppHelper::truncate( $this->option_label, $truncate ) ) . '</option>';
78 }
79 }
80 }
81