PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / helpers / libraries / menu / item.php
vikappointments / site / helpers / libraries / menu Last commit date
horizontal 3 days ago leftboard 3 days ago abstractlist.php 3 days ago custom.php 3 days ago factory.php 3 days ago index.html 3 days ago item.php 3 days ago separator.php 3 days ago shape.php 3 days ago
item.php
171 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * Class used to represent the shape of a menu item.
16 *
17 * @since 1.5
18 */
19 abstract class MenuItemShape
20 {
21 /**
22 * The title of the separator.
23 *
24 * @var string
25 */
26 private $title;
27
28 /**
29 * The url of the separator. This value can be ignored.
30 *
31 * @var string
32 */
33 private $href;
34
35 /**
36 * A custom value to use during the building.
37 *
38 * @var string
39 */
40 private $custom;
41
42 /**
43 * If the separator is selected.
44 *
45 * @var boolean
46 */
47 private $selected;
48
49 /**
50 * The construct sets all the required attributes of this class.
51 *
52 * @param string $title The title of the menu item.
53 * @param string $href Default empty.
54 * @param boolean $selected Default false.
55 *
56 * @uses setTitle()
57 * @uses setHref()
58 * @uses setSelected()
59 */
60 public function __construct($title, $href, $selected = false)
61 {
62 $this->setTitle($title)
63 ->setHref($href)
64 ->setSelected($selected);
65 }
66
67 /**
68 * Sets the title of the menu item.
69 *
70 * @param string $title The title of the menu item.
71 *
72 * @return self This object to support chaining.
73 */
74 public function setTitle($title)
75 {
76 $this->title = $title;
77
78 return $this;
79 }
80
81 /**
82 * Returns the title of the menu item.
83 *
84 * @return string The title of the menu item.
85 */
86 public function getTitle()
87 {
88 return $this->title;
89 }
90
91 /**
92 * Sets the url of the menu item.
93 *
94 * @param string $href The url of the menu item.
95 *
96 * @return self This object to support chaining.
97 */
98 public function setHref($href)
99 {
100 $this->href = $href;
101
102 return $this;
103 }
104
105 /**
106 * Returns the url of the menu item.
107 *
108 * @return string The url of the menu item.
109 */
110 public function getHref()
111 {
112 return $this->href;
113 }
114
115 /**
116 * Sets the custom value of the menu item
117 *
118 * @param string $custom The custom value of the menu item.
119 *
120 * @return self This object to support chaining.
121 */
122 public function setCustom($custom)
123 {
124 $this->custom = $custom;
125
126 return $this;
127 }
128
129 /**
130 * Returns the custom value of the menu item.
131 *
132 * @return string The custom value of the menu item.
133 */
134 public function getCustom()
135 {
136 return $this->custom;
137 }
138
139 /**
140 * Sets if the menu item is selected or not.
141 *
142 * @param boolean $selected The selection of the menu item.
143 *
144 * @return self This object to support chaining.
145 */
146 public function setSelected($selected)
147 {
148 $this->selected = $selected;
149
150 return $this;
151 }
152
153 /**
154 * Returns true if the menu item is selected, otherwise false.
155 *
156 * @return boolean True if selected.
157 */
158 public function isSelected()
159 {
160 return $this->selected;
161 }
162
163 /**
164 * Builds and returns the html structure of the menu item.
165 * This method must be implemented to define a specific graphic of the menu item.
166 *
167 * @return string The html of the menu item.
168 */
169 abstract public function buildHtml();
170 }
171