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 / import / forms / columns / state.php
vikappointments / site / helpers / libraries / import / forms / columns Last commit date
city.php 3 days ago country.php 3 days ago currency.php 3 days ago date.php 3 days ago empgroup.php 3 days ago employee.php 3 days ago group.php 3 days ago index.html 3 days ago optiongroup.php 3 days ago service.php 3 days ago state.php 3 days ago user.php 3 days ago
state.php
66 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 * Populate the options array with the existing states,
16 * in order to support the correct placeholders while
17 * importing and exporting the records.
18 *
19 * @since 1.7.3
20 */
21 class ImportColumnState extends ImportColumn
22 {
23 /**
24 * States cache.
25 *
26 * @var array
27 */
28 private static $states = null;
29
30 /**
31 * Binds the internal properties with the given array/object.
32 *
33 * @param mixed $data Either an array or an object.
34 *
35 * @return void
36 */
37 protected function setup($data)
38 {
39 // use parent to set up data
40 parent::setup($data);
41
42 foreach (static::getStates() as $state)
43 {
44 // register state as option
45 $this->options[$state['id']] = $state['state_name'];
46 }
47 }
48
49 /**
50 * Loads a list of available states.
51 *
52 * @return array
53 */
54 protected static function getStates()
55 {
56 // load states only once
57 if (is_null(static::$states))
58 {
59 // sort states list by name ASC
60 static::$states = VAPLocations::getStates(0, 'state_name');
61 }
62
63 return static::$states;
64 }
65 }
66