PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.5.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.5.0
5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 3.1.0 All 34 releases
double-opt-in / core / HTMLSelectOption.class.php

HTMLSelectOption.class.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 5.5.0, at core/HTMLSelectOption.class.php

103 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace forge12\contactform7\CF7DoubleOptIn {
4 if (!defined('ABSPATH')) {
5 exit;
6 }
7
8 /**
9 * HTMLSelectOption converts an given array to a HTML Option List.
10 *
11 * @package forge12\contactform7\CF7DoubleOptIn
12 */
13 class HTMLSelectOption
14 {
15 /**
16 * The key of the option field
17 * @var string|int
18 */
19 private $key = '';
20 /**
21 * The value of the option field
22 * @var string|int
23 */
24 private $value = '';
25
26 /**
27 * Flag if selected or not
28 * @var bool
29 */
30 private $selected = false;
31
32 /**
33 * Create a new option list
34 */
35 public function __construct($key, $value, $selected = false)
36 {
37 $this->setKey($key);
38 $this->setValue($value);
39 $this->setSelected($selected);
40 }
41
42 /**
43 * Return the HTML String for the option value
44 * @return string
45 */
46 public function get()
47 {
48 if($this->isSelected()){
49 return '<option value="' . esc_attr($this->getKey()) . '" selected="selected">' . esc_html($this->getValue()) . '</option>';
50 }else{
51 return '<option value="' . esc_attr($this->getKey()) . '">' . esc_html($this->getValue()) . '</option>';
52 }
53 }
54
55 /**
56 * @return string
57 */
58 public function getValue(): string
59 {
60 return $this->value;
61 }
62
63 /**
64 * @param string $value
65 */
66 private function setValue(string $value)
67 {
68 $this->value = $value;
69 }
70
71 /**
72 * @return string
73 */
74 public function getKey(): string
75 {
76 return $this->key;
77 }
78
79 /**
80 * @param string $key
81 */
82 private function setKey(string $key)
83 {
84 $this->key = $key;
85 }
86
87 /**
88 * @return bool
89 */
90 public function isSelected(): bool
91 {
92 return $this->selected;
93 }
94
95 /**
96 * @param bool $selected
97 */
98 public function setSelected(bool $selected)
99 {
100 $this->selected = $selected;
101 }
102 }
103 }